If PROXY protocol v2 was enabled with dynamic certificate loading,
notably in the stream module, a segmentation fault might happen.
The reason is that during an abbreviated handshake the certificate
callback is not called, leading to NULL being returned from
SSL_get_certificate().
The fix is similar to
5784889fb.
Reported by ruokeqx.
case NGX_PROXY_PROTOCOL_TLV_SSL_SIG_ALG:
cert = SSL_get_certificate(c->ssl->connection);
+ if (cert == NULL) {
+ return NGX_DECLINED;
+ }
+
out->data = (u_char *) OBJ_nid2sn(X509_get_signature_nid(cert));
out->len = ngx_strlen(out->data);
return NGX_OK;
case NGX_PROXY_PROTOCOL_TLV_SSL_KEY_ALG:
cert = SSL_get_certificate(c->ssl->connection);
+ if (cert == NULL) {
+ return NGX_DECLINED;
+ }
+
pkey = X509_get_pubkey(cert);
if (pkey == NULL) {
return NGX_ERROR;