aboutsummaryrefslogtreecommitdiffstats
path: root/testing/litespeed/libressl.patch
blob: c3476789a46d2d88b3ee1082de38bb156fb92158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
diff --git a/src/sslpp/sslcontext.cpp b/src/sslpp/sslcontext.cpp
index a701325..341b2da 100644
--- a/src/sslpp/sslcontext.cpp
+++ b/src/sslpp/sslcontext.cpp
@@ -723,7 +723,7 @@ int SslContext::enableSpdy(int level)
 #ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
     SSL_CTX_set_alpn_select_cb(m_pCtx, SSLConntext_alpn_select_cb, this);
 #endif
-#ifdef TLSEXT_TYPE_next_proto_neg
+#if defined(TLSEXT_TYPE_next_proto_neg) || defined(LIBRESSL_VERSION_NUMBER)
     SSL_CTX_set_next_protos_advertised_cb(m_pCtx,
                                           SslConnection_ssl_npn_advertised_cb, this);
 #else
diff --git a/src/sslpp/sslutil.cpp b/src/sslpp/sslutil.cpp
index 6561c04..afd9272 100644
--- a/src/sslpp/sslutil.cpp
+++ b/src/sslpp/sslutil.cpp
@@ -851,7 +851,16 @@ int  SslUtil::getPrivateKeyPem(SSL_CTX *pCtx, AutoBuf *pBuf)
 {
     int ret = -1;
     BIO *pOut = BIO_new(BIO_s_mem());
-    EVP_PKEY *pKey = SSL_CTX_get0_privatekey(pCtx);
+    EVP_PKEY *pKey = NULL;
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
+    pKey = SSL_CTX_get0_privatekey(pCtx);
+#else
+    SSL *ssl = SSL_new(pCtx);
+    if (!ssl)
+        return ret;
+    pKey = SSL_get_privatekey(ssl);
+    SSL_free(ssl);
+#endif
 
     if (PEM_write_bio_PrivateKey(pOut, pKey, NULL, NULL, 0, NULL, NULL))
         ret = bioToBuf(pOut, pBuf);
@@ -863,7 +872,16 @@ int  SslUtil::getCertPem(SSL_CTX *pCtx, AutoBuf *pBuf)
 {
     int ret = -1;
     BIO *pOut = BIO_new(BIO_s_mem());
-    X509 *pCert = SSL_CTX_get0_certificate(pCtx);
+    X509 *pCert = NULL;
+#if OPENSSL_VERSION_NUMBER >= 0x10002000L && !defined(LIBRESSL_VERSION_NUMBER)
+    pCert = SSL_CTX_get0_certificate(pCtx);
+#else
+    SSL *ssl = SSL_new(pCtx);
+    if (!ssl)
+        return ret;
+    pCert = SSL_get_certificate(ssl);
+    SSL_free(ssl);
+#endif
 
     if (PEM_write_bio_X509(pOut, pCert))
         ret = bioToBuf(pOut, pBuf);