@@ -159,14 +159,24 @@ bool PaymentRequestPlus::getMerchant(X509_STORE* certStore, QString& merchant) c
159
159
std::string data_to_verify; // Everything but the signature
160
160
rcopy.SerializeToString (&data_to_verify);
161
161
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
163
170
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)) {
168
175
throw SSLVerifyError (" Bad signature, invalid payment request." );
169
176
}
177
+ #if OPENSSL_VERSION_NUMBER >= 0x10100000L
178
+ EVP_MD_CTX_free (ctx);
179
+ #endif
170
180
171
181
// OpenSSL API for getting human printable strings from certs is baroque.
172
182
int textlen = X509_NAME_get_text_by_NID (certname, NID_commonName, NULL , 0 );
0 commit comments