@@ -32,6 +32,7 @@ Table of Contents
32
32
+ [ bn.istype] ( #bnistype )
33
33
+ [ bn.from_binary] ( #bnfrom_binary )
34
34
+ [ bn: to_binary ] ( #bnto_binary )
35
+ + [ bn: to_hex ] ( #bnto_hex )
35
36
* [ resty.openssl.cipher] ( #restyopensslcipher )
36
37
+ [ cipher.new] ( #ciphernew )
37
38
+ [ cipher.istype] ( #cipheristype )
@@ -56,6 +57,8 @@ Table of Contents
56
57
+ [ x509.new] ( #x509new )
57
58
+ [ x509.istype] ( #x509istype )
58
59
+ [ x509: add_extension ] ( #x509add_extension )
60
+ + [ x509: digest ] ( #x509digest )
61
+ + [ x509: pubkey_digest ] ( #x509pubkey_digest )
59
62
+ [ x509: get_ * , x509: set_ * ] ( #x509get_-x509set_ )
60
63
+ [ x509: get_lifetime ] ( #x509get_lifetime )
61
64
+ [ x509: set_lifetime ] ( #x509set_lifetime )
@@ -185,11 +188,11 @@ and `DIR` are supported.
185
188
``` lua
186
189
local version = require (" resty.openssl.version" )
187
190
ngx .say (string.format (" %x" , version .version_num ))
188
- -- Outputs 101000bf
191
+ -- outputs " 101000bf"
189
192
ngx .say (version .version_text )
190
- -- Outputs OpenSSL 1.1.0k 28 May 2019
193
+ -- outputs " OpenSSL 1.1.0k 28 May 2019"
191
194
ngx .say (version .version (version .PLATFORM ))
192
- -- Outputs darwin64-x86_64-cc
195
+ -- outputs " darwin64-x86_64-cc"
193
196
```
194
197
195
198
### OPENSSL_11
@@ -336,11 +339,21 @@ ngx.say(ngx.encode_base64(bin))
336
339
337
340
Export the BIGNUM value in binary string.
338
341
342
+
343
+ ### bn: to_hex
344
+
345
+ ** syntax** : * hex, err = bn: to_hex ()*
346
+
347
+ Export the BIGNUM value in hex encoded string.
348
+
339
349
``` lua
340
350
local b , err = require (" resty.openssl.bn" ).new (23333 )
341
351
local bin , err = b :to_binary ()
342
352
ngx .say (ngx .encode_base64 (bin ))
343
353
-- outputs "WyU="
354
+ local hex , err = b :to_hex ()
355
+ ngx .say (hex )
356
+ -- outputs "5B25"
344
357
```
345
358
346
359
## resty.openssl.cipher
@@ -449,7 +462,7 @@ ngx.say(cipher)
449
462
450
463
## resty.openssl.digest
451
464
452
- Module to interact with message digest (EVP_MD ).
465
+ Module to interact with message digest (EVP_MD_CTX ).
453
466
454
467
### digest.new
455
468
@@ -581,6 +594,28 @@ local x509, err = require("resty.openssl.x509").new()
581
594
local ok , err = x509 :add_extension (extension )
582
595
```
583
596
597
+ ### x509: digest
598
+
599
+ ** syntax** : * d, err = x509: digest (digest_name?)*
600
+
601
+ Returns a digest of the DER representation of the X509 certificate object in raw binary text.
602
+
603
+ ` digest_name ` is a case-insensitive string of digest algorithm name.
604
+ To view a list of digest algorithms implemented, use ` openssl list -digest-algorithms ` .
605
+
606
+ If ` digest_name ` is omitted, it's by default to ` sha1 ` .
607
+
608
+ ### x509: pubkey_digest
609
+
610
+ ** syntax** : * d, err = x509: pubkey_digest (digest_name?)*
611
+
612
+ Returns a digest of the DER representation of the pubkey in the X509 object in raw binary text.
613
+
614
+ ` digest_name ` is a case-insensitive string of digest algorithm name.
615
+ To view a list of digest algorithms implemented, use ` openssl list -digest-algorithms ` .
616
+
617
+ If ` digest_name ` is omitted, it's by default to ` sha1 ` .
618
+
584
619
### x509: get_ * , x509: set_ *
585
620
586
621
** syntax** : * ok, err = x509: set_attribute (instance)*
@@ -605,7 +640,7 @@ local x509, err = require("resty.openssl.x509").new()
605
640
err = x509 :set_not_before (ngx .time ())
606
641
local not_before , err = x509 :get_not_before ()
607
642
ngx .say (not_before )
608
- -- Outputs 1571875065
643
+ -- outputs 1571875065
609
644
```
610
645
611
646
### x509: get_lifetime
@@ -712,7 +747,7 @@ Returns `true` if table is an instance of `altname`. Returns `false` otherwise.
712
747
713
748
** syntax** : * altname, err = altname: add (key, value)*
714
749
715
- Adds a name to altname stack, first argument is case-insensitive and can be selection of
750
+ Adds a name to altname stack, first argument is case-insensitive and can be one of
716
751
717
752
RFC822Name
718
753
RFC822
@@ -845,8 +880,8 @@ If you plan to use this library on an untested version of OpenSSL (like custom b
845
880
TODO
846
881
====
847
882
848
- - review get0 function calls to ensure there's no double free
849
- - find a way to test memory leak
883
+ - test memory leak
884
+ - add tests for x509 getters/setters
850
885
851
886
[ Back to TOC] ( #table-of-contents )
852
887
0 commit comments