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)); \
108 CRYPTO_add(&x509->references, 1, CRYPTO_LOCK_X509);
148 x509 = PEM_read_bio_X509(in, &x,
NULL,
NULL);
152 x509 = d2i_X509_bio(in, &x);
167 if (
self == other)
return self;
194 if ((len = i2d_X509(x509,
NULL)) <= 0)
198 if (i2d_X509(x509, &p) <= 0)
217 out = BIO_new(BIO_s_mem());
220 if (!PEM_write_bio_X509(out, x509)) {
242 out = BIO_new(BIO_s_mem());
245 if (!X509_print(out, x509)) {
259 ossl_x509_to_req(
VALUE self)
266 if (!(req = X509_to_X509_REQ(x509,
NULL, EVP_md5()))) {
287 return LONG2NUM(X509_get_version(x509));
300 if ((ver =
NUM2LONG(version)) < 0) {
304 if (!X509_set_version(x509, ver)) {
336 x509->cert_info->serialNumber =
354 out = BIO_new(BIO_s_mem());
357 if (!i2a_ASN1_OBJECT(out, x509->cert_info->signature->algorithm)) {
377 if (!(name = X509_get_subject_name(x509))) {
412 if(!(name = X509_get_issuer_name(x509))) {
444 ASN1_UTCTIME *asn1time;
447 if (!(asn1time = X509_get_notBefore(x509))) {
466 if (!X509_time_adj(X509_get_notBefore(x509), 0, &sec)) {
484 if (!(asn1time = X509_get_notAfter(x509))) {
503 if (!X509_time_adj(X509_get_notAfter(x509), 0, &sec)) {
521 if (!(pkey = X509_get_pubkey(x509))) {
538 if (!X509_set_pubkey(x509,
GetPKeyPtr(key))) {
559 if (!X509_sign(x509, pkey, md)) {
581 if ((i = X509_verify(x509, pkey)) < 0) {
606 if (!X509_check_private_key(x509, pkey)) {
627 count = X509_get_ext_count(x509);
632 for (i=0; i<
count; i++) {
633 ext = X509_get_ext(x509, i);
657 sk_X509_EXTENSION_pop_free(x509->cert_info->extensions, X509_EXTENSION_free);
658 x509->cert_info->extensions =
NULL;
659 for (i=0; i<RARRAY_LEN(ary); i++) {
662 if (!X509_add_ext(x509, ext, -1)) {
663 X509_EXTENSION_free(ext);
666 X509_EXTENSION_free(ext);
684 if (!X509_add_ext(x509, ext, -1)) {
685 X509_EXTENSION_free(ext);
688 X509_EXTENSION_free(ext);