Class: OpenSSL::OCSP::CertificateId
- Inherits:
-
Object
- Object
- OpenSSL::OCSP::CertificateId
- Defined in:
- ext/openssl/ossl_ocsp.c
Instance Method Summary collapse
-
#cmp(other) ⇒ Boolean
Compares this certificate id with other and returns
trueif they are the same. -
#cmp_issuer(other) ⇒ Boolean
Compares this certificate id’s issuer with other and returns
trueif they are the same. -
#hash_algorithm ⇒ String
Returns the ln (long name) of the hash algorithm used to generate the issuerNameHash and the issuerKeyHash values.
-
#initialize(*args) ⇒ Object
constructor
Creates a new OpenSSL::OCSP::CertificateId for the given subject and issuer X509 certificates.
-
#initialize_copy(other) ⇒ Object
:nodoc:.
-
#issuer_key_hash ⇒ String
Returns the issuerKeyHash of this certificate ID, the hash of the issuer’s public key.
-
#issuer_name_hash ⇒ String
Returns the issuerNameHash of this certificate ID, the hash of the issuer’s distinguished name calculated with the hashAlgorithm.
-
#serial ⇒ Integer
Returns the serial number of the certificate for which status is being requested.
-
#to_der ⇒ String
Encodes this certificate identifier into a DER-encoded string.
Constructor Details
#OpenSSL::OCSP::CertificateId.new(subject, issuer, digest = nil) ⇒ Object #OpenSSL::OCSP::CertificateId.new(der_string) ⇒ Object #OpenSSL::OCSP::CertificateId.new(obj) ⇒ Object
Creates a new OpenSSL::OCSP::CertificateId for the given subject and issuer X509 certificates. The digest is a digest algorithm that is used to compute the hash values. This defaults to SHA-1.
If only one argument is given, decodes it as DER representation of a certificate ID or generates certificate ID from the object that responds to the to_der method.
1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 |
# File 'ext/openssl/ossl_ocsp.c', line 1438 static VALUE ossl_ocspcid_initialize(int argc, VALUE *argv, VALUE self) { OCSP_CERTID *id, *newid; VALUE subject, issuer, digest; GetOCSPCertId(self, id); if (rb_scan_args(argc, argv, "12", &subject, &issuer, &digest) == 1) { VALUE arg; const unsigned char *p; arg = ossl_to_der_if_possible(subject); StringValue(arg); p = (unsigned char *)RSTRING_PTR(arg); newid = d2i_OCSP_CERTID(NULL, &p, RSTRING_LEN(arg)); if (!newid) ossl_raise(eOCSPError, "d2i_OCSP_CERTID"); } else { X509 *x509s, *x509i; const EVP_MD *md; VALUE md_holder; x509s = GetX509CertPtr(subject); /* NO NEED TO DUP */ x509i = GetX509CertPtr(issuer); /* NO NEED TO DUP */ md = NIL_P(digest) ? NULL : ossl_evp_md_fetch(digest, &md_holder); newid = OCSP_cert_to_id(md, x509s, x509i); if (!newid) ossl_raise(eOCSPError, "OCSP_cert_to_id"); } SetOCSPCertId(self, newid); OCSP_CERTID_free(id); return self; } |
Instance Method Details
#cmp(other) ⇒ Boolean
Compares this certificate id with other and returns true if they are the same.
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 |
# File 'ext/openssl/ossl_ocsp.c', line 1483 static VALUE ossl_ocspcid_cmp(VALUE self, VALUE other) { OCSP_CERTID *id, *id2; int result; GetOCSPCertId(self, id); GetOCSPCertId(other, id2); result = OCSP_id_cmp(id, id2); return (result == 0) ? Qtrue : Qfalse; } |
#cmp_issuer(other) ⇒ Boolean
Compares this certificate id’s issuer with other and returns true if they are the same.
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 |
# File 'ext/openssl/ossl_ocsp.c', line 1504 static VALUE ossl_ocspcid_cmp_issuer(VALUE self, VALUE other) { OCSP_CERTID *id, *id2; int result; GetOCSPCertId(self, id); GetOCSPCertId(other, id2); result = OCSP_id_issuer_cmp(id, id2); return (result == 0) ? Qtrue : Qfalse; } |
#hash_algorithm ⇒ String
Returns the ln (long name) of the hash algorithm used to generate the issuerNameHash and the issuerKeyHash values.
1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 |
# File 'ext/openssl/ossl_ocsp.c', line 1591 static VALUE ossl_ocspcid_get_hash_algorithm(VALUE self) { OCSP_CERTID *id; ASN1_OBJECT *oid; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, &oid, NULL, NULL, id); return ossl_asn1obj_to_string_long_name(oid); } |
#initialize_copy(other) ⇒ Object
:nodoc:
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
# File 'ext/openssl/ossl_ocsp.c', line 1405 static VALUE ossl_ocspcid_initialize_copy(VALUE self, VALUE other) { OCSP_CERTID *cid, *cid_old, *cid_new; rb_check_frozen(self); GetOCSPCertId(self, cid_old); GetOCSPCertId(other, cid); cid_new = OCSP_CERTID_dup(cid); if (!cid_new) ossl_raise(eOCSPError, "OCSP_CERTID_dup"); SetOCSPCertId(self, cid_new); OCSP_CERTID_free(cid_old); return self; } |
#issuer_key_hash ⇒ String
Returns the issuerKeyHash of this certificate ID, the hash of the issuer’s public key.
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 |
# File 'ext/openssl/ossl_ocsp.c', line 1567 static VALUE ossl_ocspcid_get_issuer_key_hash(VALUE self) { OCSP_CERTID *id; ASN1_OCTET_STRING *key_hash; VALUE ret; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, NULL, &key_hash, NULL, id); ret = rb_str_new(NULL, ASN1_STRING_length(key_hash) * 2); ossl_bin2hex(ASN1_STRING_get0_data(key_hash), RSTRING_PTR(ret), ASN1_STRING_length(key_hash)); return ret; } |
#issuer_name_hash ⇒ String
Returns the issuerNameHash of this certificate ID, the hash of the issuer’s distinguished name calculated with the hashAlgorithm.
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 |
# File 'ext/openssl/ossl_ocsp.c', line 1543 static VALUE ossl_ocspcid_get_issuer_name_hash(VALUE self) { OCSP_CERTID *id; ASN1_OCTET_STRING *name_hash; VALUE ret; GetOCSPCertId(self, id); OCSP_id_get0_info(&name_hash, NULL, NULL, NULL, id); ret = rb_str_new(NULL, ASN1_STRING_length(name_hash) * 2); ossl_bin2hex(ASN1_STRING_get0_data(name_hash), RSTRING_PTR(ret), ASN1_STRING_length(name_hash)); return ret; } |
#serial ⇒ Integer
Returns the serial number of the certificate for which status is being requested.
1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 |
# File 'ext/openssl/ossl_ocsp.c', line 1524 static VALUE ossl_ocspcid_get_serial(VALUE self) { OCSP_CERTID *id; ASN1_INTEGER *serial; GetOCSPCertId(self, id); OCSP_id_get0_info(NULL, NULL, NULL, &serial, id); return asn1integer_to_num(serial); } |
#to_der ⇒ String
Encodes this certificate identifier into a DER-encoded string.
1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 |
# File 'ext/openssl/ossl_ocsp.c', line 1608 static VALUE ossl_ocspcid_to_der(VALUE self) { OCSP_CERTID *id; VALUE str; long len; unsigned char *p; GetOCSPCertId(self, id); if ((len = i2d_OCSP_CERTID(id, NULL)) <= 0) ossl_raise(eOCSPError, NULL); str = rb_str_new(0, len); p = (unsigned char *)RSTRING_PTR(str); if (i2d_OCSP_CERTID(id, &p) <= 0) ossl_raise(eOCSPError, NULL); ossl_str_adjust(str, p); return str; } |