Latest...
This commit is contained in:
@@ -2709,13 +2709,80 @@ ngx_ssl_ocsp_log_error(ngx_log_t *log, u_char *buf, size_t len)
|
||||
|
||||
#else
|
||||
|
||||
static ngx_int_t ngx_ssl_stapling_file(ngx_conf_t *cf, ngx_ssl_t *ssl, X509 *cert,
|
||||
ngx_str_t *file, ngx_str_t *responder, ngx_uint_t verify);
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_stapling(ngx_conf_t *cf, ngx_ssl_t *ssl, ngx_str_t *file,
|
||||
ngx_str_t *responder, ngx_uint_t verify)
|
||||
{
|
||||
X509 *cert;
|
||||
|
||||
for (cert = SSL_CTX_get_ex_data(ssl->ctx, ngx_ssl_certificate_index);
|
||||
cert;
|
||||
cert = X509_get_ex_data(cert, ngx_ssl_next_certificate_index))
|
||||
{
|
||||
if (file->len) {
|
||||
if (ngx_ssl_stapling_file(cf, ssl, cert, file, responder, verify)
|
||||
!= NGX_OK)
|
||||
{
|
||||
return NGX_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
// SSL_CTX_set_tlsext_status_cb(ssl->ctx, ngx_ssl_certificate_status_callback);
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
ngx_int_t
|
||||
ngx_ssl_stapling_file(ngx_conf_t *cf, ngx_ssl_t *ssl, X509 *cert,
|
||||
ngx_str_t *file, ngx_str_t *responder, ngx_uint_t verify)
|
||||
{
|
||||
#ifdef BORINGSSL_MAKE_DELETER
|
||||
/*ngx_log_error(NGX_LOG_WARN, ssl->log, 0,
|
||||
"using boringssl, currently only \"ssl_stapling_file\" is supported. use it as your own risk");*/
|
||||
|
||||
BIO *bio;
|
||||
int len;
|
||||
u_char buf[2048];
|
||||
|
||||
if (ngx_conf_full_name(cf->cycle, file, 1) != NGX_OK) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
bio = BIO_new_file((char *) file->data, "r");
|
||||
if (bio == NULL) {
|
||||
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
|
||||
"BIO_new_file(\"%s\") failed", file->data);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
len = BIO_read(bio, buf, sizeof(buf) / sizeof(u_char));
|
||||
BIO_free(bio);
|
||||
bio = NULL;
|
||||
|
||||
if (len <= 0) {
|
||||
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
|
||||
"Read OCSP response file \"%s\" failed: %d", file->data, len);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (len >= 2000) {
|
||||
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
|
||||
"Unexpected OCSP response file length: %d", len);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (!SSL_CTX_set_ocsp_response(ssl->ctx, buf, len)) {
|
||||
ngx_ssl_error(NGX_LOG_EMERG, ssl->log, 0,
|
||||
"SSL_CTX_set_ocsp_response(ssl->ctx, buf, %d) failed", len);
|
||||
return NGX_ERROR;
|
||||
}
|
||||
#else
|
||||
ngx_log_error(NGX_LOG_WARN, ssl->log, 0,
|
||||
"\"ssl_stapling\" ignored, not supported");
|
||||
#endif
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user