summaryrefslogtreecommitdiff
path: root/ext/openssl/ossl_x509revoked.c
diff options
context:
space:
mode:
authorrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-29 05:47:09 +0000
committerrhe <rhe@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-08-29 05:47:09 +0000
commitc9dc0164b8ad1cb23faf6120749bcc349a7bfd45 (patch)
tree831281099f54c0be80293785761a46688a0711f3 /ext/openssl/ossl_x509revoked.c
parent28bf4d545fb7674fcdc99c93ba7476d320551d11 (diff)
import Ruby/OpenSSL 2.0.0.beta.1
* NEWS, {ext,test,sample}/openssl: Import Ruby/OpenSSL 2.0.0.beta.1. ext/openssl is now converted into a default gem. The full commit history since r55538 can be found at: https://github.com/ruby/openssl/compare/08e1881f5663...v2.0.0.beta.1 [Feature #9612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl_x509revoked.c')
-rw-r--r--ext/openssl/ossl_x509revoked.c49
1 files changed, 42 insertions, 7 deletions
diff --git a/ext/openssl/ossl_x509revoked.c b/ext/openssl/ossl_x509revoked.c
index 067bec8..7960ea3 100644
--- a/ext/openssl/ossl_x509revoked.c
+++ b/ext/openssl/ossl_x509revoked.c
@@ -110,6 +110,25 @@ ossl_x509revoked_initialize(int argc, VALUE *argv, VALUE self)
}
static VALUE
+ossl_x509revoked_initialize_copy(VALUE self, VALUE other)
+{
+ X509_REVOKED *rev, *rev_other, *rev_new;
+
+ rb_check_frozen(self);
+ GetX509Rev(self, rev);
+ SafeGetX509Rev(other, rev_other);
+
+ rev_new = X509_REVOKED_dup(rev_other);
+ if (!rev_new)
+ ossl_raise(eX509RevError, "X509_REVOKED_dup");
+
+ SetX509Rev(self, rev_new);
+ X509_REVOKED_free(rev);
+
+ return self;
+}
+
+static VALUE
ossl_x509revoked_get_serial(VALUE self)
{
X509_REVOKED *rev;
@@ -123,11 +142,15 @@ static VALUE
ossl_x509revoked_set_serial(VALUE self, VALUE num)
{
X509_REVOKED *rev;
- ASN1_INTEGER *ai;
+ ASN1_INTEGER *asn1int;
GetX509Rev(self, rev);
- ai = X509_REVOKED_get0_serialNumber(rev);
- X509_REVOKED_set_serialNumber(rev, num_to_asn1integer(num, ai));
+ asn1int = num_to_asn1integer(num, NULL);
+ if (!X509_REVOKED_set_serialNumber(rev, asn1int)) {
+ ASN1_INTEGER_free(asn1int);
+ ossl_raise(eX509RevError, "X509_REVOKED_set_serialNumber");
+ }
+ ASN1_INTEGER_free(asn1int);
return num;
}
@@ -146,10 +169,15 @@ static VALUE
ossl_x509revoked_set_time(VALUE self, VALUE time)
{
X509_REVOKED *rev;
+ ASN1_TIME *asn1time;
GetX509Rev(self, rev);
- if (!ossl_x509_time_adjust(X509_REVOKED_get0_revocationDate(rev), time))
- ossl_raise(eX509RevError, NULL);
+ asn1time = ossl_x509_time_adjust(NULL, time);
+ if (!X509_REVOKED_set_revocationDate(rev, asn1time)) {
+ ASN1_TIME_free(asn1time);
+ ossl_raise(eX509RevError, "X509_REVOKED_set_revocationDate");
+ }
+ ASN1_TIME_free(asn1time);
return time;
}
@@ -199,7 +227,7 @@ ossl_x509revoked_set_extensions(VALUE self, VALUE ary)
X509_EXTENSION_free(ext);
for (i=0; i<RARRAY_LEN(ary); i++) {
item = RARRAY_AREF(ary, i);
- ext = DupX509ExtPtr(item);
+ ext = GetX509ExtPtr(item);
if(!X509_REVOKED_add_ext(rev, ext, -1)) {
ossl_raise(eX509RevError, NULL);
}
@@ -214,7 +242,7 @@ ossl_x509revoked_add_extension(VALUE self, VALUE ext)
X509_REVOKED *rev;
GetX509Rev(self, rev);
- if(!X509_REVOKED_add_ext(rev, DupX509ExtPtr(ext), -1)) {
+ if (!X509_REVOKED_add_ext(rev, GetX509ExtPtr(ext), -1)) {
ossl_raise(eX509RevError, NULL);
}
@@ -227,12 +255,19 @@ ossl_x509revoked_add_extension(VALUE self, VALUE ext)
void
Init_ossl_x509revoked(void)
{
+#if 0
+ mOSSL = rb_define_module("OpenSSL");
+ eOSSLError = rb_define_class_under(mOSSL, "OpenSSLError", rb_eStandardError);
+ mX509 = rb_define_module_under(mOSSL, "X509");
+#endif
+
eX509RevError = rb_define_class_under(mX509, "RevokedError", eOSSLError);
cX509Rev = rb_define_class_under(mX509, "Revoked", rb_cObject);
rb_define_alloc_func(cX509Rev, ossl_x509revoked_alloc);
rb_define_method(cX509Rev, "initialize", ossl_x509revoked_initialize, -1);
+ rb_define_copy_func(cX509Rev, ossl_x509revoked_initialize_copy);
rb_define_method(cX509Rev, "serial", ossl_x509revoked_get_serial, 0);
rb_define_method(cX509Rev, "serial=", ossl_x509revoked_set_serial, 1);