aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl_ts.c
diff options
context:
space:
mode:
authorBen Toews <mastahyeti@gmail.com>2018-06-21 10:26:30 -0600
committerBen Toews <mastahyeti@gmail.com>2018-06-21 13:44:13 -0600
commitdce927cd3da74d019c3b6034956453fde885f067 (patch)
tree04e3fc954cd6b8f9439400762e22f935c343c596 /ext/openssl/ossl_ts.c
parent11e6641fca955de185f560594ca6b03bda02251e (diff)
downloadruby-openssl-dce927cd3da74d019c3b6034956453fde885f067.tar.gz
ts: get tests running/passing
A number of conventions seem to have changed, causing a fair bit of breakage: - `Data_*` was deprecated in favor of `TypedData_*` - `ossl_obj2bio` takes a `VALUE*` instead of `VALUE` now - `time_to_time_t()` was removed
Diffstat (limited to 'ext/openssl/ossl_ts.c')
-rwxr-xr-xext/openssl/ossl_ts.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/ext/openssl/ossl_ts.c b/ext/openssl/ossl_ts.c
index fbb4ee1d..9b9a6db6 100755
--- a/ext/openssl/ossl_ts.c
+++ b/ext/openssl/ossl_ts.c
@@ -187,7 +187,7 @@ ossl_tsreq_initialize(int argc, VALUE *argv, VALUE self)
}
arg = ossl_to_der_if_possible(arg);
- in = ossl_obj2bio(arg);
+ in = ossl_obj2bio(&arg);
if (!d2i_TS_REQ_bio(in, &ts_req)) {
ossl_raise(eTimestampError,
"Error when decoding the timestamp request");
@@ -530,7 +530,7 @@ ossl_ts_initialize(VALUE self, VALUE der)
BIO *in;
der = ossl_to_der_if_possible(der);
- in = ossl_obj2bio(der);
+ in = ossl_obj2bio(&der);
if (!d2i_TS_RESP_bio(in, &ts_resp)) {
ossl_raise(eTimestampError,
"Error when decoding the timestamp response");
@@ -655,13 +655,18 @@ ossl_ts_get_pkcs7(VALUE self)
{
TS_RESP *resp;
PKCS7 *p7;
+ VALUE obj;
GetTS_RESP(self, resp);
p7 = resp->token;
if (!p7)
return Qnil;
- return Data_Wrap_Struct(cPKCS7, 0, PKCS7_free, PKCS7_dup(p7));
+ obj = NewPKCS7(cPKCS7);
+ SetPKCS7(obj, PKCS7_dup(p7));
+
+ return obj;
+ // return Data_Wrap_Struct(cPKCS7, 0, PKCS7_free, PKCS7_dup(p7));
}
/*
@@ -957,7 +962,7 @@ static void int_ossl_init_roots(VALUE roots, X509_STORE * store)
X509_STORE_add_cert(store, GetX509CertPtr(roots));
}
else {
- in = ossl_obj2bio(roots);
+ in = ossl_obj2bio(&roots);
inf = PEM_X509_INFO_read_bio(in, NULL, NULL, NULL);
BIO_free(in);
if(!inf) {
@@ -1116,9 +1121,10 @@ ossl_tsfac_serial_cb(struct TS_resp_ctx *ctx, void *data)
static int
ossl_tsfac_time_cb(struct TS_resp_ctx *ctx, void *data, long *sec, long *usec)
{
- VALUE time = *((VALUE *)data);
- time_t secs = time_to_time_t(time);
- *sec = (long) secs;
+ VALUE time_v = *((VALUE *)data);
+ if (rb_obj_is_instance_of(time_v, rb_cTime))
+ time_v = rb_funcall(time_v, rb_intern("to_i"), 0);
+ *sec = NUM2LONG(time_v);;
*usec = 0;
return 1;
}
@@ -1236,7 +1242,7 @@ ossl_tsfac_create_ts(VALUE self, VALUE key, VALUE certificate, VALUE request)
TS_RESP_CTX_add_md(ctx, EVP_get_digestbyname(OBJ_nid2sn(NID_sha512)));
str = rb_funcall(request, rb_intern("to_der"), 0);
- req_bio = ossl_obj2bio(str);
+ req_bio = ossl_obj2bio(&str);
response = TS_RESP_create_response(ctx, req_bio);
if (!response) {
err_msg = "Error during response generation";