int VerifyCertByIssuer(X509 *cert, X509 *issuer) { int res = 0; EVP_PKEY *pubkey = 0; if (X509_check_issued(issuer, cert) != X509_V_OK) { goto end; } pubkey = X509_get_pubkey(issuer); if (!X509_verify(cert, pubkey)) { goto end; } res = 1; end: if (pubkey) { EVP_PKEY_free(pubkey); } return res; }