@@ -12,7 +12,8 @@ Table of Contents
12
12
- [ Status] ( #status )
13
13
- [ Synopsis] ( #synopsis )
14
14
* [ resty.openssl] ( #restyopenssl )
15
- + [ openssl.luaossl_compat] ( #opensslluaossl-compat )
15
+ + [ openssl.luaossl_compat] ( #opensslluaossl_compat )
16
+ + [ openssl.resty_hmac_compat] ( #opensslresty_hmac_compat )
16
17
* [ resty.openssl.version] ( #restyopensslversion )
17
18
+ [ version_num] ( #version_num )
18
19
+ [ version_text] ( #version_text )
@@ -230,6 +231,15 @@ Note that not all `luaossl` API has been implemented, please check readme for so
230
231
231
232
[ Back to TOC] ( #table-of-contents )
232
233
234
+ ### openssl.resty_hmac_compat
235
+
236
+ ** syntax** : * openssl.resty_hmac_compat()*
237
+
238
+ Call this function before ` require("resty.hmac") ` to allow these two libraries play nice with
239
+ each other. This function is not available with OpenSSL 1.0.
240
+
241
+ [ Back to TOC] ( #table-of-contents )
242
+
233
243
## resty.openssl.version
234
244
235
245
A module to provide version info.
@@ -302,46 +312,34 @@ Module to interact with private keys and public keys (EVP_PKEY).
302
312
303
313
** syntax** : * pk, err = pkey.new(config)*
304
314
305
- ** syntax** : * pk, err = pkey.new(string, opts ?)*
315
+ ** syntax** : * pk, err = pkey.new(string, format ?)*
306
316
307
317
** syntax** : * pk, err = pkey.new()*
308
318
309
319
Creates a new pkey instance. The first argument can be:
310
320
311
- 1 . A ` config ` table to create a new PKEY pair. Which defaults to:
321
+ 1 . A table which defaults to:
312
322
313
323
``` lua
314
- pkey . new ( {
315
- type = ' RSA' ,
316
- bits = 2048 ,
317
- exp = 65537
318
- })
324
+ {
325
+ type = ' RSA' ,
326
+ bits = 2048 ,
327
+ exp = 65537
328
+ }
319
329
```
320
330
321
331
to create EC private key:
322
332
323
333
``` lua
324
- pkey .new ({
325
- type = ' EC' ,
326
- curve = ' primve196v1' ,
327
- })
328
- ```
329
-
330
- 2 . A ` string ` of private or public key in PEM or DER format; optionally accpet a table ` opts `
331
- to explictly load ` format ` and key ` type ` . When loading a key in PEM format,
332
- ` passphrase ` or ` passphrase_cb ` may be provided to decrypt the key.
333
-
334
- ``` lua
335
- pkey .new (pem_or_der_text , {
336
- format = " *" , -- choice of "PEM", "DER" or "*" for auto detect
337
- type = " *" , -- choice of "p"r for privatekey, "pu" for public key and "*" for auto detect
338
- passphrase = " secret password" , -- the PEM encryption passphrase
339
- passphrase_cb = function ()
340
- return " secret password"
341
- end , -- the PEM encryption passphrase callback function
334
+ {
335
+ type = ' EC' ,
336
+ curve = ' primve196v1' ,
342
337
}
343
-
344
338
```
339
+
340
+ 2 . A string of private or public key in PEM or DER format; optionally tells the library
341
+ to explictly decode the key using ` format ` , which can be a choice of ` PER ` , ` DER ` or ` * `
342
+ for auto detect.
345
343
3 . ` nil ` to create a 2048 bits RSA key.
346
344
4 . A ` EVP_PKEY* ` pointer, to return a wrapped ` pkey ` instance. Normally user won't use this
347
345
approach. User shouldn't free the pointer on their own, since the pointer is not copied.
@@ -365,7 +363,7 @@ parameter of RSA key is supported. Each value of the returned table is a
365
363
[ resty.openssl.bn] ( #restyopensslbn ) instance.
366
364
367
365
``` lua
368
- local pk , err = require (" resty.openssl.pkey " ) .new ()
366
+ local pk , err = require (" resty.openssl" ). pkey .new ()
369
367
local parameters , err = pk :get_parameters ()
370
368
local e = parameters .e
371
369
ngx .say (ngx .encode_base64 (e :to_binary ()))
@@ -383,8 +381,8 @@ instance. The `digest` parameter must be a [resty.openssl.digest](#restyopenssld
383
381
instance. Returns the signed raw binary and error if any.
384
382
385
383
``` lua
386
- local pk , err = require (" resty.openssl.pkey " ) .new ()
387
- local digest , err = require (" resty.openssl.digest " ) .new (" SHA256" )
384
+ local pk , err = require (" resty.openssl" ). pkey .new ()
385
+ local digest , err = require (" resty.openssl" ). digest .new (" SHA256" )
388
386
digest :update (" dog" )
389
387
local signature , err = pk :sign (digest )
390
388
ngx .say (ngx .encode_base64 (signature ))
@@ -913,7 +911,7 @@ ngx.say(not_before)
913
911
err = x509 :set_basic_constraints_critical (true )
914
912
```
915
913
916
- If type is a table, setter requires a table with case-insensitive keys to set;
914
+ If type is a table, setter requires a table with case-insentive keys to set;
917
915
getter returns the value of the given case-insensitive key or a table of all keys if no key provided.
918
916
919
917
``` lua
@@ -1629,7 +1627,7 @@ Returns the name of extension as ASN.1 Object. User can further use helper funct
1629
1627
1630
1628
### extension: text
1631
1629
1632
- ** syntax** : * txt, err = extension: text ()*
1630
+ ** syntax** : * txt, err = extension: text (table )*
1633
1631
1634
1632
Returns the text representation of extension
1635
1633
@@ -1643,14 +1641,6 @@ ngx.say(extension:text())
1643
1641
1644
1642
[ Back to TOC] ( #table-of-contents )
1645
1643
1646
- ### extension: tostring
1647
-
1648
- ** syntax** : * txt, err = extension: tostring ()*
1649
-
1650
- Same as [ extension: text ] ( #extensiontext ) .
1651
-
1652
- [ Back to TOC] ( #table-of-contents )
1653
-
1654
1644
## resty.openssl.x509.extension.dist_points
1655
1645
1656
1646
Module to interact with CRL Distribution Points(DIST_POINT stack).
@@ -1848,11 +1838,9 @@ certificates bundle. For example, the package in Debian/Ubuntu is called `ca-cer
1848
1838
1849
1839
### store: add
1850
1840
1851
- ** syntax** : * ok, err = store: add (x509_or_crl )*
1841
+ ** syntax** : * ok, err = store: add (x509 )*
1852
1842
1853
- Adds a X.509 or a CRL object into store.
1854
- The argument must be a [ resty.openssl.x509] ( #restyopensslx509 ) instance or a
1855
- [ resty.openssl.x509.store] ( #restyopensslx509store ) instance.
1843
+ Adds a X.509 object into store. The argument must be a [ resty.openssl.x509] ( #restyopensslx509 ) instance.
1856
1844
1857
1845
[ Back to TOC] ( #table-of-contents )
1858
1846
@@ -1882,9 +1870,8 @@ Verifies a X.509 object with the store. The first argument must be
1882
1870
[ resty.openssl.x509] ( #restyopensslx509 ) instance. Optionally accept a validation chain as second
1883
1871
argument, which must be a [ resty.openssl.x509.chain] ( #restyopensslx509chain ) instance.
1884
1872
1885
- If verification succeed, and ` return_chain ` is set to true, returns the proof of validation as a
1886
- [ resty.openssl.x509.chain] ( #restyopensslx509chain ) ; otherwise
1887
- returns ` true ` only. If verification failed, returns ` nil ` and error explaining the reason.
1873
+ If verification succeed, and ` return_chain ` is set to true, returns the proof of validation; otherwise
1874
+ returns ` true ` . If verification failed, returns ` nil ` and error explaining the reason.
1888
1875
1889
1876
[ Back to TOC] ( #table-of-contents )
1890
1877
@@ -1998,6 +1985,10 @@ same.
1998
1985
If you plan to use this library on an untested version of OpenSSL (like custom builds or pre releases),
1999
1986
[ this] ( https://abi-laboratory.pro/index.php?view=timeline&l=openssl ) can be a good source to consult.
2000
1987
1988
+ TODO
1989
+ ====
1990
+
1991
+ - add tests for x509 getters/setters
2001
1992
2002
1993
[ Back to TOC] ( #table-of-contents )
2003
1994
@@ -2007,7 +1998,7 @@ Copyright and License
2007
1998
2008
1999
This module is licensed under the BSD license.
2009
2000
2010
- Copyright (C) 2019
-2020 , by fffonion
< [email protected] > .
2001
+ Copyright (C) 2019, by fffonion
< [email protected] > .
2011
2002
2012
2003
All rights reserved.
2013
2004
0 commit comments