openssl 3.2.4 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +180 -29
- data/History.md +69 -42
- data/README.md +11 -7
- data/ext/openssl/extconf.rb +6 -5
- data/ext/openssl/openssl_missing.c +1 -2
- data/ext/openssl/openssl_missing.h +1 -28
- data/ext/openssl/ossl.c +8 -10
- data/ext/openssl/ossl.h +13 -10
- data/ext/openssl/ossl_asn1.c +77 -273
- data/ext/openssl/ossl_asn1.h +1 -19
- data/ext/openssl/ossl_bio.c +1 -1
- data/ext/openssl/ossl_bio.h +1 -1
- data/ext/openssl/ossl_bn.c +12 -12
- data/ext/openssl/ossl_bn.h +1 -2
- data/ext/openssl/ossl_cipher.c +5 -5
- data/ext/openssl/ossl_cipher.h +1 -4
- data/ext/openssl/ossl_config.c +10 -9
- data/ext/openssl/ossl_config.h +1 -1
- data/ext/openssl/ossl_digest.c +39 -21
- data/ext/openssl/ossl_digest.h +1 -4
- data/ext/openssl/ossl_engine.c +3 -3
- data/ext/openssl/ossl_engine.h +1 -4
- data/ext/openssl/ossl_hmac.c +3 -3
- data/ext/openssl/ossl_hmac.h +1 -4
- data/ext/openssl/ossl_kdf.c +5 -5
- data/ext/openssl/ossl_ns_spki.c +13 -12
- data/ext/openssl/ossl_ns_spki.h +1 -5
- data/ext/openssl/ossl_ocsp.c +16 -16
- data/ext/openssl/ossl_ocsp.h +1 -8
- data/ext/openssl/ossl_pkcs12.c +54 -3
- data/ext/openssl/ossl_pkcs12.h +1 -4
- data/ext/openssl/ossl_pkcs7.c +69 -22
- data/ext/openssl/ossl_pkcs7.h +2 -22
- data/ext/openssl/ossl_pkey.c +22 -63
- data/ext/openssl/ossl_pkey.h +3 -14
- data/ext/openssl/ossl_pkey_dh.c +2 -4
- data/ext/openssl/ossl_pkey_dsa.c +2 -4
- data/ext/openssl/ossl_pkey_ec.c +6 -8
- data/ext/openssl/ossl_pkey_rsa.c +2 -4
- data/ext/openssl/ossl_provider.c +3 -1
- data/ext/openssl/ossl_rand.c +3 -3
- data/ext/openssl/ossl_rand.h +1 -4
- data/ext/openssl/ossl_ssl.c +71 -52
- data/ext/openssl/ossl_ssl.h +1 -1
- data/ext/openssl/ossl_ts.c +77 -19
- data/ext/openssl/ossl_ts.h +1 -1
- data/ext/openssl/ossl_x509.c +1 -1
- data/ext/openssl/ossl_x509.h +7 -26
- data/ext/openssl/ossl_x509attr.c +30 -32
- data/ext/openssl/ossl_x509cert.c +48 -9
- data/ext/openssl/ossl_x509crl.c +13 -9
- data/ext/openssl/ossl_x509ext.c +12 -21
- data/ext/openssl/ossl_x509name.c +8 -10
- data/ext/openssl/ossl_x509req.c +10 -6
- data/ext/openssl/ossl_x509revoked.c +5 -6
- data/ext/openssl/ossl_x509store.c +21 -14
- data/lib/openssl/asn1.rb +188 -0
- data/lib/openssl/bn.rb +1 -1
- data/lib/openssl/buffering.rb +13 -3
- data/lib/openssl/cipher.rb +1 -1
- data/lib/openssl/digest.rb +1 -1
- data/lib/openssl/marshal.rb +1 -1
- data/lib/openssl/ssl.rb +68 -4
- data/lib/openssl/version.rb +1 -1
- data/lib/openssl/x509.rb +1 -1
- data/lib/openssl.rb +2 -1
- metadata +9 -4
- /data/{LICENSE.txt → COPYING} +0 -0
data/ext/openssl/ossl_x509attr.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
30
|
VALUE cX509Attr;
|
|
31
|
-
VALUE eX509AttrError;
|
|
31
|
+
static VALUE eX509AttrError;
|
|
32
32
|
|
|
33
33
|
static void
|
|
34
34
|
ossl_x509attr_free(void *ptr)
|
|
@@ -48,7 +48,7 @@ static const rb_data_type_t ossl_x509attr_type = {
|
|
|
48
48
|
* Public
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509attr_new(
|
|
51
|
+
ossl_x509attr_new(X509_ATTRIBUTE *attr)
|
|
52
52
|
{
|
|
53
53
|
X509_ATTRIBUTE *new;
|
|
54
54
|
VALUE obj;
|
|
@@ -57,8 +57,7 @@ ossl_x509attr_new(const X509_ATTRIBUTE *attr)
|
|
|
57
57
|
if (!attr) {
|
|
58
58
|
new = X509_ATTRIBUTE_new();
|
|
59
59
|
} else {
|
|
60
|
-
|
|
61
|
-
new = X509_ATTRIBUTE_dup((X509_ATTRIBUTE *)attr);
|
|
60
|
+
new = X509_ATTRIBUTE_dup(attr);
|
|
62
61
|
}
|
|
63
62
|
if (!new) {
|
|
64
63
|
ossl_raise(eX509AttrError, NULL);
|
|
@@ -175,7 +174,7 @@ static VALUE
|
|
|
175
174
|
ossl_x509attr_get_oid(VALUE self)
|
|
176
175
|
{
|
|
177
176
|
X509_ATTRIBUTE *attr;
|
|
178
|
-
|
|
177
|
+
ASN1_OBJECT *oid;
|
|
179
178
|
BIO *out;
|
|
180
179
|
VALUE ret;
|
|
181
180
|
int nid;
|
|
@@ -187,7 +186,7 @@ ossl_x509attr_get_oid(VALUE self)
|
|
|
187
186
|
else{
|
|
188
187
|
if (!(out = BIO_new(BIO_s_mem())))
|
|
189
188
|
ossl_raise(eX509AttrError, NULL);
|
|
190
|
-
i2a_ASN1_OBJECT(out,
|
|
189
|
+
i2a_ASN1_OBJECT(out, oid);
|
|
191
190
|
ret = ossl_membio2str(out);
|
|
192
191
|
}
|
|
193
192
|
|
|
@@ -202,37 +201,36 @@ static VALUE
|
|
|
202
201
|
ossl_x509attr_set_value(VALUE self, VALUE value)
|
|
203
202
|
{
|
|
204
203
|
X509_ATTRIBUTE *attr;
|
|
205
|
-
|
|
206
|
-
int i, asn1_tag;
|
|
204
|
+
GetX509Attr(self, attr);
|
|
207
205
|
|
|
208
206
|
OSSL_Check_Kind(value, cASN1Data);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
ossl_raise(eASN1Error, "ASN1::Set has non-array value");
|
|
207
|
+
VALUE der = ossl_to_der(value);
|
|
208
|
+
const unsigned char *p = (const unsigned char *)RSTRING_PTR(der);
|
|
209
|
+
STACK_OF(ASN1_TYPE) *sk = d2i_ASN1_SET_ANY(NULL, &p, RSTRING_LEN(der));
|
|
210
|
+
if (!sk)
|
|
211
|
+
ossl_raise(eX509AttrError, "attribute value must be ASN1::Set");
|
|
215
212
|
|
|
216
|
-
GetX509Attr(self, attr);
|
|
217
213
|
if (X509_ATTRIBUTE_count(attr)) { /* populated, reset first */
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
214
|
+
ASN1_OBJECT *obj = X509_ATTRIBUTE_get0_object(attr);
|
|
215
|
+
X509_ATTRIBUTE *new_attr = X509_ATTRIBUTE_create_by_OBJ(NULL, obj, 0, NULL, -1);
|
|
216
|
+
if (!new_attr) {
|
|
217
|
+
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
|
|
218
|
+
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_create_by_OBJ");
|
|
219
|
+
}
|
|
220
|
+
SetX509Attr(self, new_attr);
|
|
221
|
+
X509_ATTRIBUTE_free(attr);
|
|
222
|
+
attr = new_attr;
|
|
225
223
|
}
|
|
226
224
|
|
|
227
|
-
for (i = 0; i <
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
ASN1_TYPE_free(a1type);
|
|
225
|
+
for (int i = 0; i < sk_ASN1_TYPE_num(sk); i++) {
|
|
226
|
+
ASN1_TYPE *a1type = sk_ASN1_TYPE_value(sk, i);
|
|
227
|
+
if (!X509_ATTRIBUTE_set1_data(attr, ASN1_TYPE_get(a1type),
|
|
228
|
+
a1type->value.ptr, -1)) {
|
|
229
|
+
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
|
|
230
|
+
ossl_raise(eX509AttrError, "X509_ATTRIBUTE_set1_data");
|
|
231
|
+
}
|
|
235
232
|
}
|
|
233
|
+
sk_ASN1_TYPE_pop_free(sk, ASN1_TYPE_free);
|
|
236
234
|
|
|
237
235
|
return value;
|
|
238
236
|
}
|
|
@@ -257,7 +255,7 @@ ossl_x509attr_get_value(VALUE self)
|
|
|
257
255
|
|
|
258
256
|
count = X509_ATTRIBUTE_count(attr);
|
|
259
257
|
for (i = 0; i < count; i++)
|
|
260
|
-
|
|
258
|
+
sk_ASN1_TYPE_push(sk, X509_ATTRIBUTE_get0_type(attr, i));
|
|
261
259
|
|
|
262
260
|
if ((len = i2d_ASN1_SET_ANY(sk, NULL)) <= 0) {
|
|
263
261
|
sk_ASN1_TYPE_free(sk);
|
data/ext/openssl/ossl_x509cert.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
30
|
VALUE cX509Cert;
|
|
31
|
-
VALUE eX509CertError;
|
|
31
|
+
static VALUE eX509CertError;
|
|
32
32
|
|
|
33
33
|
static void
|
|
34
34
|
ossl_x509_free(void *ptr)
|
|
@@ -48,7 +48,7 @@ static const rb_data_type_t ossl_x509_type = {
|
|
|
48
48
|
* Public
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509_new(
|
|
51
|
+
ossl_x509_new(X509 *x509)
|
|
52
52
|
{
|
|
53
53
|
X509 *new;
|
|
54
54
|
VALUE obj;
|
|
@@ -57,8 +57,7 @@ ossl_x509_new(const X509 *x509)
|
|
|
57
57
|
if (!x509) {
|
|
58
58
|
new = X509_new();
|
|
59
59
|
} else {
|
|
60
|
-
|
|
61
|
-
new = X509_dup((X509 *)x509);
|
|
60
|
+
new = X509_dup(x509);
|
|
62
61
|
}
|
|
63
62
|
if (!new) {
|
|
64
63
|
ossl_raise(eX509CertError, NULL);
|
|
@@ -352,7 +351,7 @@ static VALUE
|
|
|
352
351
|
ossl_x509_get_subject(VALUE self)
|
|
353
352
|
{
|
|
354
353
|
X509 *x509;
|
|
355
|
-
|
|
354
|
+
X509_NAME *name;
|
|
356
355
|
|
|
357
356
|
GetX509(self, x509);
|
|
358
357
|
if (!(name = X509_get_subject_name(x509))) { /* NO DUP - don't free! */
|
|
@@ -387,7 +386,7 @@ static VALUE
|
|
|
387
386
|
ossl_x509_get_issuer(VALUE self)
|
|
388
387
|
{
|
|
389
388
|
X509 *x509;
|
|
390
|
-
|
|
389
|
+
X509_NAME *name;
|
|
391
390
|
|
|
392
391
|
GetX509(self, x509);
|
|
393
392
|
if(!(name = X509_get_issuer_name(x509))) { /* NO DUP - don't free! */
|
|
@@ -540,7 +539,11 @@ ossl_x509_sign(VALUE self, VALUE key, VALUE digest)
|
|
|
540
539
|
const EVP_MD *md;
|
|
541
540
|
|
|
542
541
|
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
|
|
543
|
-
|
|
542
|
+
if (NIL_P(digest)) {
|
|
543
|
+
md = NULL; /* needed for some key types, e.g. Ed25519 */
|
|
544
|
+
} else {
|
|
545
|
+
md = ossl_evp_get_digestbyname(digest);
|
|
546
|
+
}
|
|
544
547
|
GetX509(self, x509);
|
|
545
548
|
if (!X509_sign(x509, pkey, md)) {
|
|
546
549
|
ossl_raise(eX509CertError, NULL);
|
|
@@ -609,6 +612,7 @@ ossl_x509_get_extensions(VALUE self)
|
|
|
609
612
|
{
|
|
610
613
|
X509 *x509;
|
|
611
614
|
int count, i;
|
|
615
|
+
X509_EXTENSION *ext;
|
|
612
616
|
VALUE ary;
|
|
613
617
|
|
|
614
618
|
GetX509(self, x509);
|
|
@@ -618,7 +622,7 @@ ossl_x509_get_extensions(VALUE self)
|
|
|
618
622
|
}
|
|
619
623
|
ary = rb_ary_new2(count);
|
|
620
624
|
for (i=0; i<count; i++) {
|
|
621
|
-
|
|
625
|
+
ext = X509_get_ext(x509, i); /* NO DUP - don't free! */
|
|
622
626
|
rb_ary_push(ary, ossl_x509ext_new(ext));
|
|
623
627
|
}
|
|
624
628
|
|
|
@@ -707,6 +711,38 @@ ossl_x509_eq(VALUE self, VALUE other)
|
|
|
707
711
|
return !X509_cmp(a, b) ? Qtrue : Qfalse;
|
|
708
712
|
}
|
|
709
713
|
|
|
714
|
+
#ifdef HAVE_I2D_RE_X509_TBS
|
|
715
|
+
/*
|
|
716
|
+
* call-seq:
|
|
717
|
+
* cert.tbs_bytes => string
|
|
718
|
+
*
|
|
719
|
+
* Returns the DER-encoded bytes of the certificate's to be signed certificate.
|
|
720
|
+
* This is mainly useful for validating embedded certificate transparency signatures.
|
|
721
|
+
*/
|
|
722
|
+
static VALUE
|
|
723
|
+
ossl_x509_tbs_bytes(VALUE self)
|
|
724
|
+
{
|
|
725
|
+
X509 *x509;
|
|
726
|
+
int len;
|
|
727
|
+
unsigned char *p0;
|
|
728
|
+
VALUE str;
|
|
729
|
+
|
|
730
|
+
GetX509(self, x509);
|
|
731
|
+
len = i2d_re_X509_tbs(x509, NULL);
|
|
732
|
+
if (len <= 0) {
|
|
733
|
+
ossl_raise(eX509CertError, "i2d_re_X509_tbs");
|
|
734
|
+
}
|
|
735
|
+
str = rb_str_new(NULL, len);
|
|
736
|
+
p0 = (unsigned char *)RSTRING_PTR(str);
|
|
737
|
+
if (i2d_re_X509_tbs(x509, &p0) <= 0) {
|
|
738
|
+
ossl_raise(eX509CertError, "i2d_re_X509_tbs");
|
|
739
|
+
}
|
|
740
|
+
ossl_str_adjust(str, p0);
|
|
741
|
+
|
|
742
|
+
return str;
|
|
743
|
+
}
|
|
744
|
+
#endif
|
|
745
|
+
|
|
710
746
|
struct load_chained_certificates_arguments {
|
|
711
747
|
VALUE certificates;
|
|
712
748
|
X509 *certificate;
|
|
@@ -999,4 +1035,7 @@ Init_ossl_x509cert(void)
|
|
|
999
1035
|
rb_define_method(cX509Cert, "add_extension", ossl_x509_add_extension, 1);
|
|
1000
1036
|
rb_define_method(cX509Cert, "inspect", ossl_x509_inspect, 0);
|
|
1001
1037
|
rb_define_method(cX509Cert, "==", ossl_x509_eq, 1);
|
|
1038
|
+
#ifdef HAVE_I2D_RE_X509_TBS
|
|
1039
|
+
rb_define_method(cX509Cert, "tbs_bytes", ossl_x509_tbs_bytes, 0);
|
|
1040
|
+
#endif
|
|
1002
1041
|
}
|
data/ext/openssl/ossl_x509crl.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
/*
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
|
-
VALUE cX509CRL;
|
|
31
|
-
VALUE eX509CRLError;
|
|
30
|
+
static VALUE cX509CRL;
|
|
31
|
+
static VALUE eX509CRLError;
|
|
32
32
|
|
|
33
33
|
static void
|
|
34
34
|
ossl_x509crl_free(void *ptr)
|
|
@@ -58,14 +58,13 @@ GetX509CRLPtr(VALUE obj)
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
VALUE
|
|
61
|
-
ossl_x509crl_new(
|
|
61
|
+
ossl_x509crl_new(X509_CRL *crl)
|
|
62
62
|
{
|
|
63
63
|
X509_CRL *tmp;
|
|
64
64
|
VALUE obj;
|
|
65
65
|
|
|
66
66
|
obj = NewX509CRL(cX509CRL);
|
|
67
|
-
|
|
68
|
-
tmp = crl ? X509_CRL_dup((X509_CRL *)crl) : X509_CRL_new();
|
|
67
|
+
tmp = crl ? X509_CRL_dup(crl) : X509_CRL_new();
|
|
69
68
|
if(!tmp) ossl_raise(eX509CRLError, NULL);
|
|
70
69
|
SetX509CRL(obj, tmp);
|
|
71
70
|
|
|
@@ -275,7 +274,7 @@ ossl_x509crl_get_revoked(VALUE self)
|
|
|
275
274
|
{
|
|
276
275
|
X509_CRL *crl;
|
|
277
276
|
int i, num;
|
|
278
|
-
|
|
277
|
+
X509_REVOKED *rev;
|
|
279
278
|
VALUE ary, revoked;
|
|
280
279
|
|
|
281
280
|
GetX509CRL(self, crl);
|
|
@@ -351,7 +350,11 @@ ossl_x509crl_sign(VALUE self, VALUE key, VALUE digest)
|
|
|
351
350
|
|
|
352
351
|
GetX509CRL(self, crl);
|
|
353
352
|
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
|
|
354
|
-
|
|
353
|
+
if (NIL_P(digest)) {
|
|
354
|
+
md = NULL; /* needed for some key types, e.g. Ed25519 */
|
|
355
|
+
} else {
|
|
356
|
+
md = ossl_evp_get_digestbyname(digest);
|
|
357
|
+
}
|
|
355
358
|
if (!X509_CRL_sign(crl, pkey, md)) {
|
|
356
359
|
ossl_raise(eX509CRLError, NULL);
|
|
357
360
|
}
|
|
@@ -441,6 +444,7 @@ ossl_x509crl_get_extensions(VALUE self)
|
|
|
441
444
|
{
|
|
442
445
|
X509_CRL *crl;
|
|
443
446
|
int count, i;
|
|
447
|
+
X509_EXTENSION *ext;
|
|
444
448
|
VALUE ary;
|
|
445
449
|
|
|
446
450
|
GetX509CRL(self, crl);
|
|
@@ -451,7 +455,7 @@ ossl_x509crl_get_extensions(VALUE self)
|
|
|
451
455
|
}
|
|
452
456
|
ary = rb_ary_new2(count);
|
|
453
457
|
for (i=0; i<count; i++) {
|
|
454
|
-
|
|
458
|
+
ext = X509_CRL_get_ext(crl, i); /* NO DUP - don't free! */
|
|
455
459
|
rb_ary_push(ary, ossl_x509ext_new(ext));
|
|
456
460
|
}
|
|
457
461
|
|
data/ext/openssl/ossl_x509ext.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
* Classes
|
|
42
42
|
*/
|
|
43
43
|
VALUE cX509Ext;
|
|
44
|
-
VALUE cX509ExtFactory;
|
|
45
|
-
VALUE eX509ExtError;
|
|
44
|
+
static VALUE cX509ExtFactory;
|
|
45
|
+
static VALUE eX509ExtError;
|
|
46
46
|
|
|
47
47
|
static void
|
|
48
48
|
ossl_x509ext_free(void *ptr)
|
|
@@ -62,7 +62,7 @@ static const rb_data_type_t ossl_x509ext_type = {
|
|
|
62
62
|
* Public
|
|
63
63
|
*/
|
|
64
64
|
VALUE
|
|
65
|
-
ossl_x509ext_new(
|
|
65
|
+
ossl_x509ext_new(X509_EXTENSION *ext)
|
|
66
66
|
{
|
|
67
67
|
X509_EXTENSION *new;
|
|
68
68
|
VALUE obj;
|
|
@@ -71,8 +71,7 @@ ossl_x509ext_new(const X509_EXTENSION *ext)
|
|
|
71
71
|
if (!ext) {
|
|
72
72
|
new = X509_EXTENSION_new();
|
|
73
73
|
} else {
|
|
74
|
-
|
|
75
|
-
new = X509_EXTENSION_dup((X509_EXTENSION *)ext);
|
|
74
|
+
new = X509_EXTENSION_dup(ext);
|
|
76
75
|
}
|
|
77
76
|
if (!new) {
|
|
78
77
|
ossl_raise(eX509ExtError, NULL);
|
|
@@ -347,20 +346,12 @@ ossl_x509ext_set_value(VALUE self, VALUE data)
|
|
|
347
346
|
GetX509Ext(self, ext);
|
|
348
347
|
data = ossl_to_der_if_possible(data);
|
|
349
348
|
StringValue(data);
|
|
349
|
+
asn1s = X509_EXTENSION_get_data(ext);
|
|
350
350
|
|
|
351
|
-
asn1s = ASN1_OCTET_STRING_new();
|
|
352
|
-
if (!asn1s)
|
|
353
|
-
ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_new");
|
|
354
351
|
if (!ASN1_OCTET_STRING_set(asn1s, (unsigned char *)RSTRING_PTR(data),
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set");
|
|
352
|
+
RSTRING_LENINT(data))) {
|
|
353
|
+
ossl_raise(eX509ExtError, "ASN1_OCTET_STRING_set");
|
|
358
354
|
}
|
|
359
|
-
if (!X509_EXTENSION_set_data(ext, asn1s)) {
|
|
360
|
-
ASN1_OCTET_STRING_free(asn1s);
|
|
361
|
-
ossl_raise(eX509ExtError, "X509_EXTENSION_set_data");
|
|
362
|
-
}
|
|
363
|
-
ASN1_OCTET_STRING_free(asn1s);
|
|
364
355
|
|
|
365
356
|
return data;
|
|
366
357
|
}
|
|
@@ -380,7 +371,7 @@ static VALUE
|
|
|
380
371
|
ossl_x509ext_get_oid(VALUE obj)
|
|
381
372
|
{
|
|
382
373
|
X509_EXTENSION *ext;
|
|
383
|
-
|
|
374
|
+
ASN1_OBJECT *extobj;
|
|
384
375
|
BIO *out;
|
|
385
376
|
VALUE ret;
|
|
386
377
|
int nid;
|
|
@@ -392,7 +383,7 @@ ossl_x509ext_get_oid(VALUE obj)
|
|
|
392
383
|
else{
|
|
393
384
|
if (!(out = BIO_new(BIO_s_mem())))
|
|
394
385
|
ossl_raise(eX509ExtError, NULL);
|
|
395
|
-
i2a_ASN1_OBJECT(out,
|
|
386
|
+
i2a_ASN1_OBJECT(out, extobj);
|
|
396
387
|
ret = ossl_membio2str(out);
|
|
397
388
|
}
|
|
398
389
|
|
|
@@ -420,13 +411,13 @@ static VALUE
|
|
|
420
411
|
ossl_x509ext_get_value_der(VALUE obj)
|
|
421
412
|
{
|
|
422
413
|
X509_EXTENSION *ext;
|
|
423
|
-
|
|
414
|
+
ASN1_OCTET_STRING *value;
|
|
424
415
|
|
|
425
416
|
GetX509Ext(obj, ext);
|
|
426
417
|
if ((value = X509_EXTENSION_get_data(ext)) == NULL)
|
|
427
418
|
ossl_raise(eX509ExtError, NULL);
|
|
428
419
|
|
|
429
|
-
return
|
|
420
|
+
return rb_str_new((const char *)value->data, value->length);
|
|
430
421
|
}
|
|
431
422
|
|
|
432
423
|
static VALUE
|
data/ext/openssl/ossl_x509name.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
/*
|
|
33
33
|
* Classes
|
|
34
34
|
*/
|
|
35
|
-
VALUE cX509Name;
|
|
36
|
-
VALUE eX509NameError;
|
|
35
|
+
static VALUE cX509Name;
|
|
36
|
+
static VALUE eX509NameError;
|
|
37
37
|
|
|
38
38
|
static void
|
|
39
39
|
ossl_x509name_free(void *ptr)
|
|
@@ -53,7 +53,7 @@ static const rb_data_type_t ossl_x509name_type = {
|
|
|
53
53
|
* Public
|
|
54
54
|
*/
|
|
55
55
|
VALUE
|
|
56
|
-
ossl_x509name_new(
|
|
56
|
+
ossl_x509name_new(X509_NAME *name)
|
|
57
57
|
{
|
|
58
58
|
X509_NAME *new;
|
|
59
59
|
VALUE obj;
|
|
@@ -62,8 +62,7 @@ ossl_x509name_new(const X509_NAME *name)
|
|
|
62
62
|
if (!name) {
|
|
63
63
|
new = X509_NAME_new();
|
|
64
64
|
} else {
|
|
65
|
-
|
|
66
|
-
new = X509_NAME_dup((X509_NAME *)name);
|
|
65
|
+
new = X509_NAME_dup(name);
|
|
67
66
|
}
|
|
68
67
|
if (!new) {
|
|
69
68
|
ossl_raise(eX509NameError, NULL);
|
|
@@ -361,7 +360,7 @@ ossl_x509name_to_a(VALUE self)
|
|
|
361
360
|
}
|
|
362
361
|
ret = rb_ary_new2(entries);
|
|
363
362
|
for (i=0; i<entries; i++) {
|
|
364
|
-
if (!(entry =
|
|
363
|
+
if (!(entry = X509_NAME_get_entry(name, i))) {
|
|
365
364
|
ossl_raise(eX509NameError, NULL);
|
|
366
365
|
}
|
|
367
366
|
if (!i2t_ASN1_OBJECT(long_name, sizeof(long_name),
|
|
@@ -375,9 +374,8 @@ ossl_x509name_to_a(VALUE self)
|
|
|
375
374
|
short_name = OBJ_nid2sn(nid);
|
|
376
375
|
vname = rb_str_new2(short_name); /*do not free*/
|
|
377
376
|
}
|
|
378
|
-
value =
|
|
379
|
-
ary = rb_ary_new3(3, vname, asn1str_to_str(value),
|
|
380
|
-
INT2NUM(ASN1_STRING_type(value)));
|
|
377
|
+
value = X509_NAME_ENTRY_get_data(entry);
|
|
378
|
+
ary = rb_ary_new3(3, vname, asn1str_to_str(value), INT2NUM(value->type));
|
|
381
379
|
rb_ary_push(ret, ary);
|
|
382
380
|
}
|
|
383
381
|
return ret;
|
data/ext/openssl/ossl_x509req.c
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
/*
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
|
-
VALUE cX509Req;
|
|
31
|
-
VALUE eX509ReqError;
|
|
30
|
+
static VALUE cX509Req;
|
|
31
|
+
static VALUE eX509ReqError;
|
|
32
32
|
|
|
33
33
|
static void
|
|
34
34
|
ossl_x509req_free(void *ptr)
|
|
@@ -230,7 +230,7 @@ static VALUE
|
|
|
230
230
|
ossl_x509req_get_subject(VALUE self)
|
|
231
231
|
{
|
|
232
232
|
X509_REQ *req;
|
|
233
|
-
|
|
233
|
+
X509_NAME *name;
|
|
234
234
|
|
|
235
235
|
GetX509Req(self, req);
|
|
236
236
|
if (!(name = X509_REQ_get_subject_name(req))) { /* NO DUP - don't free */
|
|
@@ -312,7 +312,11 @@ ossl_x509req_sign(VALUE self, VALUE key, VALUE digest)
|
|
|
312
312
|
|
|
313
313
|
GetX509Req(self, req);
|
|
314
314
|
pkey = GetPrivPKeyPtr(key); /* NO NEED TO DUP */
|
|
315
|
-
|
|
315
|
+
if (NIL_P(digest)) {
|
|
316
|
+
md = NULL; /* needed for some key types, e.g. Ed25519 */
|
|
317
|
+
} else {
|
|
318
|
+
md = ossl_evp_get_digestbyname(digest);
|
|
319
|
+
}
|
|
316
320
|
if (!X509_REQ_sign(req, pkey, md)) {
|
|
317
321
|
ossl_raise(eX509ReqError, NULL);
|
|
318
322
|
}
|
|
@@ -348,7 +352,7 @@ ossl_x509req_get_attributes(VALUE self)
|
|
|
348
352
|
{
|
|
349
353
|
X509_REQ *req;
|
|
350
354
|
int count, i;
|
|
351
|
-
|
|
355
|
+
X509_ATTRIBUTE *attr;
|
|
352
356
|
VALUE ary;
|
|
353
357
|
|
|
354
358
|
GetX509Req(self, req);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* Classes
|
|
29
29
|
*/
|
|
30
30
|
VALUE cX509Rev;
|
|
31
|
-
VALUE eX509RevError;
|
|
31
|
+
static VALUE eX509RevError;
|
|
32
32
|
|
|
33
33
|
static void
|
|
34
34
|
ossl_x509rev_free(void *ptr)
|
|
@@ -48,7 +48,7 @@ static const rb_data_type_t ossl_x509rev_type = {
|
|
|
48
48
|
* PUBLIC
|
|
49
49
|
*/
|
|
50
50
|
VALUE
|
|
51
|
-
ossl_x509revoked_new(
|
|
51
|
+
ossl_x509revoked_new(X509_REVOKED *rev)
|
|
52
52
|
{
|
|
53
53
|
X509_REVOKED *new;
|
|
54
54
|
VALUE obj;
|
|
@@ -57,8 +57,7 @@ ossl_x509revoked_new(const X509_REVOKED *rev)
|
|
|
57
57
|
if (!rev) {
|
|
58
58
|
new = X509_REVOKED_new();
|
|
59
59
|
} else {
|
|
60
|
-
|
|
61
|
-
new = X509_REVOKED_dup((X509_REVOKED *)rev);
|
|
60
|
+
new = X509_REVOKED_dup(rev);
|
|
62
61
|
}
|
|
63
62
|
if (!new) {
|
|
64
63
|
ossl_raise(eX509RevError, NULL);
|
|
@@ -190,7 +189,7 @@ ossl_x509revoked_get_extensions(VALUE self)
|
|
|
190
189
|
{
|
|
191
190
|
X509_REVOKED *rev;
|
|
192
191
|
int count, i;
|
|
193
|
-
|
|
192
|
+
X509_EXTENSION *ext;
|
|
194
193
|
VALUE ary;
|
|
195
194
|
|
|
196
195
|
GetX509Rev(self, rev);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
/*
|
|
7
7
|
* This program is licensed under the same licence as Ruby.
|
|
8
|
-
* (See the file '
|
|
8
|
+
* (See the file 'COPYING'.)
|
|
9
9
|
*/
|
|
10
10
|
#include "ossl.h"
|
|
11
11
|
|
|
@@ -108,9 +108,9 @@ ossl_verify_cb_call(VALUE proc, int ok, X509_STORE_CTX *ctx)
|
|
|
108
108
|
/*
|
|
109
109
|
* Classes
|
|
110
110
|
*/
|
|
111
|
-
VALUE cX509Store;
|
|
112
|
-
VALUE cX509StoreContext;
|
|
113
|
-
VALUE eX509StoreError;
|
|
111
|
+
static VALUE cX509Store;
|
|
112
|
+
static VALUE cX509StoreContext;
|
|
113
|
+
static VALUE eX509StoreError;
|
|
114
114
|
|
|
115
115
|
static void
|
|
116
116
|
ossl_x509store_mark(void *ptr)
|
|
@@ -223,7 +223,6 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
223
223
|
rb_iv_set(self, "@error", Qnil);
|
|
224
224
|
rb_iv_set(self, "@error_string", Qnil);
|
|
225
225
|
rb_iv_set(self, "@chain", Qnil);
|
|
226
|
-
rb_iv_set(self, "@time", Qnil);
|
|
227
226
|
|
|
228
227
|
return self;
|
|
229
228
|
}
|
|
@@ -329,7 +328,16 @@ ossl_x509store_set_trust(VALUE self, VALUE trust)
|
|
|
329
328
|
static VALUE
|
|
330
329
|
ossl_x509store_set_time(VALUE self, VALUE time)
|
|
331
330
|
{
|
|
332
|
-
|
|
331
|
+
X509_STORE *store;
|
|
332
|
+
X509_VERIFY_PARAM *param;
|
|
333
|
+
|
|
334
|
+
GetX509Store(self, store);
|
|
335
|
+
#ifdef HAVE_X509_STORE_GET0_PARAM
|
|
336
|
+
param = X509_STORE_get0_param(store);
|
|
337
|
+
#else
|
|
338
|
+
param = store->param;
|
|
339
|
+
#endif
|
|
340
|
+
X509_VERIFY_PARAM_set_time(param, NUM2LONG(rb_Integer(time)));
|
|
333
341
|
return time;
|
|
334
342
|
}
|
|
335
343
|
|
|
@@ -521,8 +529,10 @@ static void
|
|
|
521
529
|
ossl_x509stctx_free(void *ptr)
|
|
522
530
|
{
|
|
523
531
|
X509_STORE_CTX *ctx = ptr;
|
|
524
|
-
|
|
525
|
-
|
|
532
|
+
if (X509_STORE_CTX_get0_untrusted(ctx))
|
|
533
|
+
sk_X509_pop_free(X509_STORE_CTX_get0_untrusted(ctx), X509_free);
|
|
534
|
+
if (X509_STORE_CTX_get0_cert(ctx))
|
|
535
|
+
X509_free(X509_STORE_CTX_get0_cert(ctx));
|
|
526
536
|
X509_STORE_CTX_free(ctx);
|
|
527
537
|
}
|
|
528
538
|
|
|
@@ -562,7 +572,6 @@ ossl_x509stctx_new(X509_STORE_CTX *ctx)
|
|
|
562
572
|
static VALUE ossl_x509stctx_set_flags(VALUE, VALUE);
|
|
563
573
|
static VALUE ossl_x509stctx_set_purpose(VALUE, VALUE);
|
|
564
574
|
static VALUE ossl_x509stctx_set_trust(VALUE, VALUE);
|
|
565
|
-
static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
|
|
566
575
|
|
|
567
576
|
/*
|
|
568
577
|
* call-seq:
|
|
@@ -573,7 +582,7 @@ static VALUE ossl_x509stctx_set_time(VALUE, VALUE);
|
|
|
573
582
|
static VALUE
|
|
574
583
|
ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
|
|
575
584
|
{
|
|
576
|
-
VALUE store, cert, chain
|
|
585
|
+
VALUE store, cert, chain;
|
|
577
586
|
X509_STORE_CTX *ctx;
|
|
578
587
|
X509_STORE *x509st;
|
|
579
588
|
X509 *x509 = NULL;
|
|
@@ -597,8 +606,6 @@ ossl_x509stctx_initialize(int argc, VALUE *argv, VALUE self)
|
|
|
597
606
|
sk_X509_pop_free(x509s, X509_free);
|
|
598
607
|
ossl_raise(eX509StoreError, "X509_STORE_CTX_init");
|
|
599
608
|
}
|
|
600
|
-
if (!NIL_P(t = rb_iv_get(store, "@time")))
|
|
601
|
-
ossl_x509stctx_set_time(self, t);
|
|
602
609
|
rb_iv_set(self, "@verify_callback", rb_iv_get(store, "@verify_callback"));
|
|
603
610
|
rb_iv_set(self, "@cert", cert);
|
|
604
611
|
|
|
@@ -629,7 +636,7 @@ ossl_x509stctx_verify(VALUE self)
|
|
|
629
636
|
ossl_clear_error();
|
|
630
637
|
return Qfalse;
|
|
631
638
|
default:
|
|
632
|
-
ossl_raise(
|
|
639
|
+
ossl_raise(eX509StoreError, "X509_verify_cert");
|
|
633
640
|
}
|
|
634
641
|
}
|
|
635
642
|
|
|
@@ -763,7 +770,7 @@ static VALUE
|
|
|
763
770
|
ossl_x509stctx_get_curr_crl(VALUE self)
|
|
764
771
|
{
|
|
765
772
|
X509_STORE_CTX *ctx;
|
|
766
|
-
|
|
773
|
+
X509_CRL *crl;
|
|
767
774
|
|
|
768
775
|
GetX509StCtx(self, ctx);
|
|
769
776
|
crl = X509_STORE_CTX_get0_current_crl(ctx);
|