Skip to content

Commit b05b1af

Browse files
committed
Fix qt/paymentrequestplus.cpp for OpenSSL 1.1 API.
This avoids a compile failure on newly installed debian stretch systems.
1 parent bae1eef commit b05b1af

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/qt/paymentrequestplus.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,24 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
159159
std::string data_to_verify; // Everything but the signature
160160
rcopy.SerializeToString(&data_to_verify);
161161

162-
EVP_MD_CTX ctx;
162+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
163+
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
164+
if (!ctx) throw SSLVerifyError("Error allocating OpenSSL context.");
165+
#else
166+
EVP_MD_CTX _ctx;
167+
EVP_MD_CTX *ctx;
168+
ctx = &_ctx;
169+
#endif
163170
EVP_PKEY *pubkey = X509_get_pubkey(signing_cert);
164-
EVP_MD_CTX_init(&ctx);
165-
if (!EVP_VerifyInit_ex(&ctx, digestAlgorithm, NULL) ||
166-
!EVP_VerifyUpdate(&ctx, data_to_verify.data(), data_to_verify.size()) ||
167-
!EVP_VerifyFinal(&ctx, (const unsigned char*)paymentRequest.signature().data(), (unsigned int)paymentRequest.signature().size(), pubkey)) {
171+
EVP_MD_CTX_init(ctx);
172+
if (!EVP_VerifyInit_ex(ctx, digestAlgorithm, NULL) ||
173+
!EVP_VerifyUpdate(ctx, data_to_verify.data(), data_to_verify.size()) ||
174+
!EVP_VerifyFinal(ctx, (const unsigned char*)paymentRequest.signature().data(), (unsigned int)paymentRequest.signature().size(), pubkey)) {
168175
throw SSLVerifyError("Bad signature, invalid payment request.");
169176
}
177+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
178+
EVP_MD_CTX_free(ctx);
179+
#endif
170180

171181
// OpenSSL API for getting human printable strings from certs is baroque.
172182
int textlen = X509_NAME_get_text_by_NID(certname, NID_commonName, NULL, 0);

0 commit comments

Comments
 (0)