1. 程式人生 > >openssl 驗證證書是否是某個CA證書籤發

openssl 驗證證書是否是某個CA證書籤發

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;
}