13 #define WrapX509(klass, obj, x509) do { \
15 ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
17 (obj) = Data_Wrap_Struct((klass), 0, X509_free, (x509)); \
19 #define GetX509(obj, x509) do { \
20 Data_Get_Struct((obj), X509, (x509)); \
22 ossl_raise(rb_eRuntimeError, "CERT wasn't initialized!"); \
25 #define SafeGetX509(obj, x509) do { \
26 OSSL_Check_Kind((obj), cX509Cert); \
27 GetX509((obj), (x509)); \
107 CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
147 x509 = PEM_read_bio_X509(in, &x,
NULL,
NULL);
151 x509 = d2i_X509_bio(in, &x);
166 if (
self == other)
return self;
193 if ((len = i2d_X509(x509,
NULL)) <= 0)
197 if (i2d_X509(x509, &p) <= 0)
216 out = BIO_new(BIO_s_mem());
219 if (!PEM_write_bio_X509(out, x509)) {
241 out = BIO_new(BIO_s_mem());
244 if (!X509_print(out, x509)) {
258 ossl_x509_to_req(
VALUE self)
265 if (!(req = X509_to_X509_REQ(x509, NULL, EVP_md5()))) {
286 return LONG2NUM(X509_get_version(x509));
299 if ((ver =
NUM2LONG(version)) < 0) {
303 if (!X509_set_version(x509, ver)) {
335 x509->cert_info->serialNumber =
353 out = BIO_new(BIO_s_mem());
356 if (!i2a_ASN1_OBJECT(out, x509->cert_info->signature->algorithm)) {
376 if (!(name = X509_get_subject_name(x509))) {
411 if(!(name = X509_get_issuer_name(x509))) {
443 ASN1_UTCTIME *asn1time;
446 if (!(asn1time = X509_get_notBefore(x509))) {
465 if (!X509_time_adj(X509_get_notBefore(x509), 0, &sec)) {
483 if (!(asn1time = X509_get_notAfter(x509))) {
502 if (!X509_time_adj(X509_get_notAfter(x509), 0, &sec)) {
520 if (!(pkey = X509_get_pubkey(x509))) {
537 if (!X509_set_pubkey(x509,
GetPKeyPtr(key))) {
558 if (!X509_sign(x509, pkey, md)) {
580 if ((i = X509_verify(x509, pkey)) < 0) {
605 if (!X509_check_private_key(x509, pkey)) {
626 count = X509_get_ext_count(x509);
631 for (i=0; i<
count; i++) {
632 ext = X509_get_ext(x509, i);
656 sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
657 x509->cert_info->extensions =
NULL;
661 if (!X509_add_ext(x509, ext, -1)) {
662 X509_EXTENSION_free(ext);
665 X509_EXTENSION_free(ext);
683 if (!X509_add_ext(x509, ext, -1)) {
684 X509_EXTENSION_free(ext);
687 X509_EXTENSION_free(ext);