@@ -14,6 +14,9 @@ Table of Contents
14
14
* [ resty.kong.tls.disable\_ session\_ reuse] ( #restykongtlsdisable_session_reuse )
15
15
* [ resty.kong.tls.get\_ full\_ client\_ certificate\_ chain] ( #restykongtlsget_full_client_certificate_chain )
16
16
* [ resty.kong.tls.set\_ upstream\_ cert\_ and\_ key] ( #restykongtlsset_upstream_cert_and_key )
17
+ * [ resty.kong.tls.set\_ upstream\_ ssl\_ trusted\_ store] ( #restykongtlsset_upstream_ssl_trusted_store )
18
+ * [ resty.kong.tls.set\_ upstream\_ ssl\_ verify] ( #restykongtlsset_upstream_ssl_verify )
19
+ * [ resty.kong.tls.set\_ upstream\_ ssl\_ verify\_ depth] ( #restykongtlsset_upstream_ssl_verify_depth )
17
20
* [ resty.kong.tls.disable\_ proxy\_ ssl] ( #restykongtlsdisable_proxy_ssl )
18
21
* [ License] ( #license )
19
22
@@ -134,6 +137,106 @@ previous ones.
134
137
135
138
[ Back to TOC] ( #table-of-contents )
136
139
140
+ resty.kong.tls.set\_ upstream\_ ssl\_ trusted\_ store
141
+ --------------------------------------------
142
+ ** syntax:** * ok, err = resty.kong.tls.set\_ upstream\_ ssl\_ trusted\_ store(store)*
143
+
144
+ ** context:** * rewrite_by_lua* ; , access_by_lua* ; , balancer_by_lua* ; *
145
+
146
+ ** subsystems:** * http*
147
+
148
+ Set upstream ssl verification trusted store of current request. Global setting set by
149
+ ` proxy_ssl_trusted_certificate ` will be overwritten for the current request.
150
+
151
+ ` store ` is a ` X509_STORE* ` cdata that can be created by
152
+ [ resty.openssl.x509.store.new] ( https://github.com/fffonion/lua-resty-openssl#storenew ) .
153
+
154
+ On success, this function returns ` true ` and future handshakes with upstream servers
155
+ will be verified with given store. Otherwise ` nil ` and a string describing the
156
+ error will be returned.
157
+
158
+ This function can be called multiple times in the same request. Later calls override
159
+ previous ones.
160
+
161
+ Example:
162
+ ``` lua
163
+ local x509 = require (" resty.openssl.x509" )
164
+ local crt , err = x509 .new ([[ -----BEGIN CERTIFICATE-----
165
+ ...
166
+ -----END CERTIFICATE-----]] )
167
+ if err then
168
+ ngx .log (ngx .ERR , " failed to parse cert: " , err )
169
+ ngx .exit (500 )
170
+ end
171
+ local store = require (" resty.openssl.x509.store" )
172
+ local st , err = store .new ()
173
+ if err then
174
+ ngx .log (ngx .ERR , " failed to create store: " , err )
175
+ ngx .exit (500 )
176
+ end
177
+ local ok , err = st :add (crt )
178
+ if err then
179
+ ngx .log (ngx .ERR , " failed to add cert to store: " , err )
180
+ ngx .exit (500 )
181
+ end
182
+ -- st:add can be called multiple times, also accept a crl
183
+ -- st:add(another_crt)
184
+ -- st:add(crl)
185
+ -- OR
186
+ -- st:use_default() to load default CA bundle
187
+ local tls = require (" resty.kong.tls" )
188
+ local ok , err = tls .set_upstream_ssl_trusted_store (st .ctx )
189
+ if err then
190
+ ngx .log (ngx .ERR , " failed to set upstream trusted store: " , err )
191
+ ngx .exit (500 )
192
+ end
193
+ local ok , err = tls .set_upstream_ssl_verify (true )
194
+ if err then
195
+ ngx .log (ngx .ERR , " failed to set upstream ssl verify: " , err )
196
+ ngx .exit (500 )
197
+ end
198
+ ```
199
+
200
+ [ Back to TOC] ( #table-of-contents )
201
+
202
+ resty.kong.tls.set\_ upstream\_ ssl\_ verify
203
+ --------------------------------------------
204
+ ** syntax:** * ok, err = resty.kong.tls.set\_ upstream\_ ssl\_ verify(verify)*
205
+
206
+ ** context:** * rewrite_by_lua* ; , access_by_lua* ; , balancer_by_lua* ; *
207
+
208
+ ** subsystems:** * http*
209
+
210
+ Set upstream ssl verification enablement of current request to the given boolean
211
+ argument ` verify ` . Global setting set by ` proxy_ssl_verify ` will be overwritten.
212
+
213
+ On success, this function returns ` true ` . Otherwise ` nil ` and a string
214
+ describing the error will be returned.
215
+
216
+ This function can be called multiple times in the same request. Later calls override
217
+ previous ones.
218
+
219
+ [ Back to TOC] ( #table-of-contents )
220
+
221
+ resty.kong.tls.set\_ upstream\_ ssl\_ verify\_ depth
222
+ --------------------------------------------
223
+ ** syntax:** * ok, err = resty.kong.tls.set\_ upstream\_ ssl\_ verify\_ depth(depth)*
224
+
225
+ ** context:** * rewrite_by_lua* ; , access_by_lua* ; , balancer_by_lua* ; *
226
+
227
+ ** subsystems:** * http*
228
+
229
+ Set upstream ssl verification depth of current request to the given non-negative integer
230
+ argument ` depth ` . Global setting set by ` proxy_ssl_verify_depth ` will be overwritten.
231
+
232
+ On success, this function returns ` true ` . Otherwise ` nil ` and a string
233
+ describing the error will be returned.
234
+
235
+ This function can be called multiple times in the same request. Later calls override
236
+ previous ones.
237
+
238
+ [ Back to TOC] ( #table-of-contents )
239
+
137
240
resty.kong.tls.disable\_ proxy\_ ssl
138
241
----------------------------------
139
242
** syntax:** * ok, err = resty.kong.tls.disable_proxy_ssl()*
@@ -172,4 +275,3 @@ limitations under the License.
172
275
```
173
276
174
277
[ Back to TOC] ( #table-of-contents )
175
-
0 commit comments