Latest update - 7655
This commit is contained in:
@@ -130,6 +130,7 @@ int ngx_ssl_connection_index;
|
||||
int ngx_ssl_server_conf_index;
|
||||
int ngx_ssl_session_cache_index;
|
||||
int ngx_ssl_session_ticket_keys_index;
|
||||
int ngx_ssl_ocsp_index;
|
||||
int ngx_ssl_certificate_index;
|
||||
int ngx_ssl_next_certificate_index;
|
||||
int ngx_ssl_certificate_name_index;
|
||||
@@ -213,6 +214,13 @@ ngx_ssl_init(ngx_log_t *log)
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_ssl_ocsp_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
|
||||
if (ngx_ssl_ocsp_index == -1) {
|
||||
ngx_ssl_error(NGX_LOG_ALERT, log, 0,
|
||||
"SSL_CTX_get_ex_new_index() failed");
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
ngx_ssl_certificate_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL,
|
||||
NULL);
|
||||
if (ngx_ssl_certificate_index == -1) {
|
||||
@@ -1603,6 +1611,7 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
{
|
||||
int n, sslerr;
|
||||
ngx_err_t err;
|
||||
ngx_int_t rc;
|
||||
|
||||
#ifdef SSL_READ_EARLY_DATA_SUCCESS
|
||||
if (c->ssl->try_early_data) {
|
||||
@@ -1610,6 +1619,10 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (c->ssl->in_ocsp) {
|
||||
return ngx_ssl_ocsp_validate(c);
|
||||
}
|
||||
|
||||
ngx_ssl_clear_error(c->log);
|
||||
|
||||
n = SSL_do_handshake(c->ssl->connection);
|
||||
@@ -1630,8 +1643,6 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
ngx_ssl_handshake_log(c);
|
||||
#endif
|
||||
|
||||
c->ssl->handshaked = 1;
|
||||
|
||||
c->recv = ngx_ssl_recv;
|
||||
c->send = ngx_ssl_write;
|
||||
c->recv_chain = ngx_ssl_recv_chain;
|
||||
@@ -1650,6 +1661,20 @@ ngx_ssl_handshake(ngx_connection_t *c)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
rc = ngx_ssl_ocsp_validate(c);
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
c->read->handler = ngx_ssl_handshake_handler;
|
||||
c->write->handler = ngx_ssl_handshake_handler;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
c->ssl->handshaked = 1;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@@ -1719,6 +1744,7 @@ ngx_ssl_try_early_data(ngx_connection_t *c)
|
||||
u_char buf;
|
||||
size_t readbytes;
|
||||
ngx_err_t err;
|
||||
ngx_int_t rc;
|
||||
|
||||
ngx_ssl_clear_error(c->log);
|
||||
|
||||
@@ -1753,7 +1779,6 @@ ngx_ssl_try_early_data(ngx_connection_t *c)
|
||||
c->ssl->early_buf = buf;
|
||||
c->ssl->early_preread = 1;
|
||||
|
||||
c->ssl->handshaked = 1;
|
||||
c->ssl->in_early = 1;
|
||||
|
||||
c->recv = ngx_ssl_recv;
|
||||
@@ -1761,6 +1786,20 @@ ngx_ssl_try_early_data(ngx_connection_t *c)
|
||||
c->recv_chain = ngx_ssl_recv_chain;
|
||||
c->send_chain = ngx_ssl_send_chain;
|
||||
|
||||
rc = ngx_ssl_ocsp_validate(c);
|
||||
|
||||
if (rc == NGX_ERROR) {
|
||||
return NGX_ERROR;
|
||||
}
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
c->read->handler = ngx_ssl_handshake_handler;
|
||||
c->write->handler = ngx_ssl_handshake_handler;
|
||||
return NGX_AGAIN;
|
||||
}
|
||||
|
||||
c->ssl->handshaked = 1;
|
||||
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
@@ -2782,6 +2821,8 @@ ngx_ssl_shutdown(ngx_connection_t *c)
|
||||
int n, sslerr, mode;
|
||||
ngx_err_t err;
|
||||
|
||||
ngx_ssl_ocsp_cleanup(c);
|
||||
|
||||
if (SSL_in_init(c->ssl->connection)) {
|
||||
/*
|
||||
* OpenSSL 1.0.2f complains if SSL_shutdown() is called during
|
||||
@@ -4963,11 +5004,14 @@ ngx_ssl_get_client_verify(ngx_connection_t *c, ngx_pool_t *pool, ngx_str_t *s)
|
||||
rc = SSL_get_verify_result(c->ssl->connection);
|
||||
|
||||
if (rc == X509_V_OK) {
|
||||
ngx_str_set(s, "SUCCESS");
|
||||
return NGX_OK;
|
||||
}
|
||||
if (ngx_ssl_ocsp_get_status(c, &str) == NGX_OK) {
|
||||
ngx_str_set(s, "SUCCESS");
|
||||
return NGX_OK;
|
||||
}
|
||||
|
||||
str = X509_verify_cert_error_string(rc);
|
||||
} else {
|
||||
str = X509_verify_cert_error_string(rc);
|
||||
}
|
||||
|
||||
s->data = ngx_pnalloc(pool, sizeof("FAILED:") - 1 + ngx_strlen(str));
|
||||
if (s->data == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user