- EVP_MD_CTX mctx;
-
- EVP_MD_CTX_init(&mctx);
- rv = do_sign_init(&mctx, pkey, md, sigopts);
+ EVP_MD_CTX *mctx = EVP_MD_CTX_create();
+ rv = do_sign_init(mctx, pkey, md, sigopts);
+ /* Note: X509_REQ_sign_ctx() calls ASN1_item_sign_ctx(), which destroys
+ * the EVP_MD_CTX we send it, so only destroy it here if the former
+ * isn't called */