854 | 854 |
int
|
855 | 855 |
ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg)
|
856 | 856 |
{
|
|
857 |
ngx_int_t rc;
|
857 | 858 |
ngx_str_t host;
|
858 | 859 |
const char *servername;
|
859 | 860 |
ngx_connection_t *c;
|
|
871 | 872 |
c = ngx_ssl_get_connection(ssl_conn);
|
872 | 873 |
|
873 | 874 |
if (c->ssl->handshaked) {
|
874 | |
return SSL_TLSEXT_ERR_OK;
|
|
875 |
*ad = SSL_AD_NO_RENEGOTIATION;
|
|
876 |
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
875 | 877 |
}
|
876 | 878 |
|
877 | 879 |
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,
|
|
885 | 887 |
|
886 | 888 |
host.data = (u_char *) servername;
|
887 | 889 |
|
888 | |
if (ngx_http_validate_host(&host, c->pool, 1) != NGX_OK) {
|
|
890 |
rc = ngx_http_validate_host(&host, c->pool, 1);
|
|
891 |
|
|
892 |
if (rc == NGX_ERROR) {
|
|
893 |
*ad = SSL_AD_INTERNAL_ERROR;
|
|
894 |
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
|
895 |
}
|
|
896 |
|
|
897 |
if (rc == NGX_DECLINED) {
|
889 | 898 |
return SSL_TLSEXT_ERR_OK;
|
890 | 899 |
}
|
891 | 900 |
|
892 | 901 |
hc = c->data;
|
893 | 902 |
|
894 | |
if (ngx_http_find_virtual_server(c, hc->addr_conf->virtual_names, &host,
|
895 | |
NULL, &cscf)
|
896 | |
!= NGX_OK)
|
897 | |
{
|
|
903 |
rc = ngx_http_find_virtual_server(c, hc->addr_conf->virtual_names, &host,
|
|
904 |
NULL, &cscf);
|
|
905 |
|
|
906 |
if (rc == NGX_ERROR) {
|
|
907 |
*ad = SSL_AD_INTERNAL_ERROR;
|
|
908 |
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
|
909 |
}
|
|
910 |
|
|
911 |
if (rc == NGX_DECLINED) {
|
898 | 912 |
return SSL_TLSEXT_ERR_OK;
|
899 | 913 |
}
|
900 | 914 |
|
901 | 915 |
hc->ssl_servername = ngx_palloc(c->pool, sizeof(ngx_str_t));
|
902 | 916 |
if (hc->ssl_servername == NULL) {
|
903 | |
return SSL_TLSEXT_ERR_OK;
|
|
917 |
*ad = SSL_AD_INTERNAL_ERROR;
|
|
918 |
return SSL_TLSEXT_ERR_ALERT_FATAL;
|
904 | 919 |
}
|
905 | 920 |
|
906 | 921 |
*hc->ssl_servername = host;
|