summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorsteve <steve>2001-02-23 13:04:20 +0000
committersteve <steve>2001-02-23 13:04:20 +0000
commit79aa0fb9b340d77f2fa888c2af56ed519236d61e (patch)
treef674d1200b21e16e7c750740e7b10ed0c77887d2 /crypto
parenta96145781eb9e699d6d86b0bd9d4a5574af1f736 (diff)
downloadopenssl-79aa0fb9b340d77f2fa888c2af56ed519236d61e.tar.gz
Make OCSP cert id code tolerate a missing issuer certificate
or serial number.
Diffstat (limited to 'crypto')
-rw-r--r--crypto/ocsp/ocsp_lib.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/crypto/ocsp/ocsp_lib.c b/crypto/ocsp/ocsp_lib.c
index 4cdc5f011..0ddf1b290 100644
--- a/crypto/ocsp/ocsp_lib.c
+++ b/crypto/ocsp/ocsp_lib.c
@@ -80,8 +80,16 @@ OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, X509 *subject, X509 *issuer)
#ifndef OPENSSL_NO_SHA1
if(!dgst) dgst = EVP_sha1();
#endif
- iname = X509_get_issuer_name(subject);
- serial = X509_get_serialNumber(subject);
+ if (subject)
+ {
+ iname = X509_get_issuer_name(subject);
+ serial = X509_get_serialNumber(subject);
+ }
+ else
+ {
+ iname = X509_get_subject_name(issuer);
+ serial = NULL;
+ }
ikey = X509_get0_pubkey_bitstr(issuer);
return OCSP_cert_id_new(dgst, iname, ikey, serial);
}
@@ -118,9 +126,12 @@ OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst,
EVP_Digest(issuerKey->data, issuerKey->length, md, &i, dgst);
if (!(ASN1_OCTET_STRING_set(cid->issuerKeyHash, md, i))) goto err;
-
- if (cid->serialNumber != NULL) ASN1_INTEGER_free(cid->serialNumber);
- if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber))) goto err;
+
+ if (serialNumber)
+ {
+ ASN1_INTEGER_free(cid->serialNumber);
+ if (!(cid->serialNumber = ASN1_INTEGER_dup(serialNumber))) goto err;
+ }
return cid;
digerr:
OCSPerr(OCSP_F_CERT_ID_NEW,OCSP_R_DIGEST_ERR);