Skip to content

Commit 3a926e1

Browse files
authored
Merge pull request #579 from rhenium/ky/libressl-3.7.0
Fix test failures with LibreSSL 3.6
2 parents ff2fe4b + 289f6e0 commit 3a926e1

File tree

4 files changed

+30
-37
lines changed

4 files changed

+30
-37
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ jobs:
5454
- openssl-1.1.1s
5555
- openssl-3.0.7
5656
- libressl-3.1.5 # EOL
57-
- libressl-3.2.7
58-
- libressl-3.3.5
59-
- libressl-3.4.2
60-
- libressl-3.5.0
57+
- libressl-3.2.7 # EOL
58+
- libressl-3.3.6 # EOL
59+
- libressl-3.4.3 # EOL
60+
- libressl-3.5.3
61+
- libressl-3.6.1
62+
- libressl-3.7.0 # Development release
6163
steps:
6264
- name: repo checkout
6365
uses: actions/checkout@v3

ext/openssl/ossl_ssl.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313

1414
#define numberof(ary) (int)(sizeof(ary)/sizeof((ary)[0]))
1515

16+
#if !defined(OPENSSL_NO_NEXTPROTONEG) && !OSSL_IS_LIBRESSL
17+
# define OSSL_USE_NEXTPROTONEG
18+
#endif
19+
1620
#if !defined(TLS1_3_VERSION) && \
17-
defined(LIBRESSL_VERSION_NUMBER) && \
18-
LIBRESSL_VERSION_NUMBER >= 0x3020000fL
21+
OSSL_LIBRESSL_PREREQ(3, 2, 0) && !OSSL_LIBRESSL_PREREQ(3, 4, 0)
1922
# define TLS1_3_VERSION 0x0304
2023
#endif
2124

@@ -703,7 +706,7 @@ ssl_npn_select_cb_common(SSL *ssl, VALUE cb, const unsigned char **out,
703706
return SSL_TLSEXT_ERR_OK;
704707
}
705708

706-
#ifndef OPENSSL_NO_NEXTPROTONEG
709+
#ifdef OSSL_USE_NEXTPROTONEG
707710
static int
708711
ssl_npn_advertise_cb(SSL *ssl, const unsigned char **out, unsigned int *outlen,
709712
void *arg)
@@ -900,7 +903,7 @@ ossl_sslctx_setup(VALUE self)
900903
val = rb_attr_get(self, id_i_verify_depth);
901904
if(!NIL_P(val)) SSL_CTX_set_verify_depth(ctx, NUM2INT(val));
902905

903-
#ifndef OPENSSL_NO_NEXTPROTONEG
906+
#ifdef OSSL_USE_NEXTPROTONEG
904907
val = rb_attr_get(self, id_i_npn_protocols);
905908
if (!NIL_P(val)) {
906909
VALUE encoded = ssl_encode_npn_protocols(val);
@@ -2446,7 +2449,7 @@ ossl_ssl_get_client_ca_list(VALUE self)
24462449
return ossl_x509name_sk2ary(ca);
24472450
}
24482451

2449-
# ifndef OPENSSL_NO_NEXTPROTONEG
2452+
# ifdef OSSL_USE_NEXTPROTONEG
24502453
/*
24512454
* call-seq:
24522455
* ssl.npn_protocol => String | nil
@@ -2782,7 +2785,7 @@ Init_ossl_ssl(void)
27822785
* end
27832786
*/
27842787
rb_attr(cSSLContext, rb_intern_const("renegotiation_cb"), 1, 1, Qfalse);
2785-
#ifndef OPENSSL_NO_NEXTPROTONEG
2788+
#ifdef OSSL_USE_NEXTPROTONEG
27862789
/*
27872790
* An Enumerable of Strings. Each String represents a protocol to be
27882791
* advertised as the list of supported protocols for Next Protocol
@@ -2988,7 +2991,7 @@ Init_ossl_ssl(void)
29882991
rb_define_method(cSSLSocket, "tmp_key", ossl_ssl_tmp_key, 0);
29892992
rb_define_method(cSSLSocket, "alpn_protocol", ossl_ssl_alpn_protocol, 0);
29902993
rb_define_method(cSSLSocket, "export_keying_material", ossl_ssl_export_keying_material, -1);
2991-
# ifndef OPENSSL_NO_NEXTPROTONEG
2994+
# ifdef OSSL_USE_NEXTPROTONEG
29922995
rb_define_method(cSSLSocket, "npn_protocol", ossl_ssl_npn_protocol, 0);
29932996
# endif
29942997
#endif

test/openssl/test_asn1.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,9 @@ def test_object_identifier
323323
assert_raise(OpenSSL::ASN1::ASN1Error) { OpenSSL::ASN1::ObjectId.new("3.0".b).to_der }
324324
assert_raise(OpenSSL::ASN1::ASN1Error) { OpenSSL::ASN1::ObjectId.new("0.40".b).to_der }
325325

326-
begin
327-
oid = (0...100).to_a.join(".").b
328-
obj = OpenSSL::ASN1::ObjectId.new(oid)
329-
assert_equal oid, obj.oid
330-
rescue OpenSSL::ASN1::ASN1Error
331-
pend "OBJ_obj2txt() not working (LibreSSL?)" if $!.message =~ /OBJ_obj2txt/
332-
raise
333-
end
326+
oid = (0...100).to_a.join(".").b
327+
obj = OpenSSL::ASN1::ObjectId.new(oid)
328+
assert_equal oid, obj.oid
334329

335330
aki = [
336331
OpenSSL::ASN1::ObjectId.new("authorityKeyIdentifier"),
@@ -404,16 +399,17 @@ def test_set
404399
def test_utctime
405400
encode_decode_test B(%w{ 17 0D }) + "160908234339Z".b,
406401
OpenSSL::ASN1::UTCTime.new(Time.utc(2016, 9, 8, 23, 43, 39))
407-
# Seconds is omitted
408-
decode_test B(%w{ 17 0B }) + "1609082343Z".b,
409-
OpenSSL::ASN1::UTCTime.new(Time.utc(2016, 9, 8, 23, 43, 0))
410402
begin
411403
# possible range of UTCTime is 1969-2068 currently
412404
encode_decode_test B(%w{ 17 0D }) + "690908234339Z".b,
413405
OpenSSL::ASN1::UTCTime.new(Time.utc(1969, 9, 8, 23, 43, 39))
414406
rescue OpenSSL::ASN1::ASN1Error
415407
pend "No negative time_t support?"
416408
end
409+
# Seconds is omitted. LibreSSL 3.6.0 requires it
410+
return if libressl?
411+
decode_test B(%w{ 17 0B }) + "1609082343Z".b,
412+
OpenSSL::ASN1::UTCTime.new(Time.utc(2016, 9, 8, 23, 43, 0))
417413
# not implemented
418414
# decode_test B(%w{ 17 11 }) + "500908234339+0930".b,
419415
# OpenSSL::ASN1::UTCTime.new(Time.new(1950, 9, 8, 23, 43, 39, "+09:30"))
@@ -432,6 +428,8 @@ def test_generalizedtime
432428
OpenSSL::ASN1::GeneralizedTime.new(Time.utc(2016, 12, 8, 19, 34, 29))
433429
encode_decode_test B(%w{ 18 0F }) + "99990908234339Z".b,
434430
OpenSSL::ASN1::GeneralizedTime.new(Time.utc(9999, 9, 8, 23, 43, 39))
431+
# LibreSSL 3.6.0 requires the seconds element
432+
return if libressl?
435433
decode_test B(%w{ 18 0D }) + "201612081934Z".b,
436434
OpenSSL::ASN1::GeneralizedTime.new(Time.utc(2016, 12, 8, 19, 34, 0))
437435
# not implemented

test/openssl/test_ssl.rb

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,7 @@ def test_alpn_protocol_selection_cancel
13791379
end
13801380

13811381
def test_npn_protocol_selection_ary
1382-
pend "NPN is not supported" unless \
1383-
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
1384-
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
1382+
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
13851383

13861384
advertised = ["http/1.1", "spdy/2"]
13871385
ctx_proc = proc { |ctx| ctx.npn_protocols = advertised }
@@ -1399,9 +1397,7 @@ def test_npn_protocol_selection_ary
13991397
end
14001398

14011399
def test_npn_protocol_selection_enum
1402-
pend "NPN is not supported" unless \
1403-
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
1404-
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
1400+
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14051401

14061402
advertised = Object.new
14071403
def advertised.each
@@ -1423,9 +1419,7 @@ def advertised.each
14231419
end
14241420

14251421
def test_npn_protocol_selection_cancel
1426-
pend "NPN is not supported" unless \
1427-
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
1428-
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
1422+
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14291423

14301424
ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["http/1.1"] }
14311425
start_server_version(:TLSv1_2, ctx_proc) { |port|
@@ -1436,9 +1430,7 @@ def test_npn_protocol_selection_cancel
14361430
end
14371431

14381432
def test_npn_advertised_protocol_too_long
1439-
pend "NPN is not supported" unless \
1440-
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
1441-
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
1433+
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14421434

14431435
ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["a" * 256] }
14441436
start_server_version(:TLSv1_2, ctx_proc) { |port|
@@ -1449,9 +1441,7 @@ def test_npn_advertised_protocol_too_long
14491441
end
14501442

14511443
def test_npn_selected_protocol_too_long
1452-
pend "NPN is not supported" unless \
1453-
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
1454-
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
1444+
return unless OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14551445

14561446
ctx_proc = Proc.new { |ctx| ctx.npn_protocols = ["http/1.1"] }
14571447
start_server_version(:TLSv1_2, ctx_proc) { |port|

0 commit comments

Comments
 (0)