Blame SOURCES/openssl-1.0.1e-copy-algo.patch

83c29f
diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c
83c29f
index 6a33b9d..76a5f9e 100644
83c29f
--- a/ssl/ssl_lib.c
83c29f
+++ b/ssl/ssl_lib.c
83c29f
@@ -3177,15 +3177,26 @@ SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl)
83c29f
 
83c29f
 SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx)
83c29f
 	{
83c29f
+	CERT *ocert = ssl->cert;
83c29f
 	if (ssl->ctx == ctx)
83c29f
 		return ssl->ctx;
83c29f
 #ifndef OPENSSL_NO_TLSEXT
83c29f
 	if (ctx == NULL)
83c29f
 		ctx = ssl->initial_ctx;
83c29f
 #endif
83c29f
-	if (ssl->cert != NULL)
83c29f
-		ssl_cert_free(ssl->cert);
83c29f
 	ssl->cert = ssl_cert_dup(ctx->cert);
83c29f
+	if (ocert)
83c29f
+		{
83c29f
+		int i;
83c29f
+		/* Copy negotiated digests from original */
83c29f
+		for (i = 0; i < SSL_PKEY_NUM; i++)
83c29f
+			{
83c29f
+			CERT_PKEY *cpk = ocert->pkeys + i;
83c29f
+			CERT_PKEY *rpk = ssl->cert->pkeys + i;
83c29f
+			rpk->digest = cpk->digest;
83c29f
+			}
83c29f
+		ssl_cert_free(ocert);
83c29f
+		}
83c29f
 	CRYPTO_add(&ctx->references,1,CRYPTO_LOCK_SSL_CTX);
83c29f
 	if (ssl->ctx != NULL)
83c29f
 		SSL_CTX_free(ssl->ctx); /* decrement reference count */