class OpenSSL::OCSP::CertificateId

Parent:
Object

An OpenSSL::OCSP::CertificateId identifies a certificate to the CA so that a status check can be performed.

Public Class Methods

OpenSSL::OCSP::CertificateId.new(subject, issuer, digest = nil) → certificate_id Show source
static VALUE
ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self)
{
    OCSP_CERTID *id, *newid;
    X509 *x509s, *x509i;
    VALUE subject, issuer, digest;
    const EVP_MD *md;

    if (rb_scan_args(argc, argv, "21", &subject, &issuer, &digest) == 0) {
        return self;
    }

    x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */
    x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */

    if (!NIL_P(digest)) {
        md = GetDigestPtr(digest);
        newid = OCSP_cert_to_id(md, x509s, x509i);
    } else {
        newid = OCSP_cert_to_id(NULL, x509s, x509i);
    }
    if(!newid)
        ossl_raise(eOCSPError, NULL);
    GetOCSPCertId(self, id);
    OCSP_CERTID_free(id);
    RDATA(self)->data = newid;

    return self;
}

Creates a new OpenSSL::OCSP::CertificateId for the given subject and issuer X509 certificates. The digest is used to compute the certificate ID and must be an OpenSSL::Digest instance.

Public Instance Methods

cmp(other) → true or false Show source
static VALUE
ossl_ocspcid_cmp(VALUE self, VALUE other)
{
    OCSP_CERTID *id, *id2;
    int result;

    GetOCSPCertId(self, id);
    SafeGetOCSPCertId(other, id2);
    result = OCSP_id_cmp(id, id2);

    return (result == 0) ? Qtrue : Qfalse;
}

Compares this certificate id with other and returns true if they are the same.

cmp_issuer(other) → true or false Show source
static VALUE
ossl_ocspcid_cmp_issuer(VALUE self, VALUE other)
{
    OCSP_CERTID *id, *id2;
    int result;

    GetOCSPCertId(self, id);
    SafeGetOCSPCertId(other, id2);
    result = OCSP_id_issuer_cmp(id, id2);

    return (result == 0) ? Qtrue : Qfalse;
}

Compares this certificate id's issuer with other and returns true if they are the same.

get_serial → Integer Show source
static VALUE
ossl_ocspcid_get_serial(VALUE self)
{
    OCSP_CERTID *id;

    GetOCSPCertId(self, id);

    return asn1integer_to_num(id->serialNumber);
}

Returns the serial number of the issuing certificate.

Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.