File tree 2 files changed +12
-12
lines changed
main/java/org/jruby/ext/openssl
2 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -1506,7 +1506,7 @@ public Primitive(Ruby runtime, RubyClass type) {
1506
1506
@ Override
1507
1507
@ JRubyMethod
1508
1508
public IRubyObject to_der (final ThreadContext context ) {
1509
- if ( value (context ).isNil () ) {
1509
+ if ( value (context ).isNil () && ! isNull () ) {
1510
1510
// MRI compatibility but avoids Java exceptions as well e.g.
1511
1511
// Java::JavaLang::NumberFormatException
1512
1512
// java.math.BigInteger.<init>(BigInteger.java:296)
@@ -1596,7 +1596,7 @@ boolean isExplicitTagging() {
1596
1596
1597
1597
@ Override
1598
1598
boolean isImplicitTagging () {
1599
- IRubyObject tagging = getInstanceVariable ( "@ tagging" );
1599
+ IRubyObject tagging = tagging ( );
1600
1600
if ( tagging .isNil () ) return true ;
1601
1601
return "IMPLICIT" .equals ( tagging .toString () );
1602
1602
}
@@ -1606,6 +1606,10 @@ boolean isEOC() {
1606
1606
return false ;
1607
1607
}
1608
1608
1609
+ private boolean isNull () {
1610
+ return "Null" .equals (getMetaClass ().getRealClass ().getBaseName ());
1611
+ }
1612
+
1609
1613
@ Override
1610
1614
byte [] toDER (final ThreadContext context ) throws IOException {
1611
1615
return toASN1 (context ).toASN1Primitive ().getEncoded (ASN1Encoding .DER );
Original file line number Diff line number Diff line change @@ -245,9 +245,7 @@ def test_encode_nested_set_to_der
245
245
end
246
246
247
247
def test_null
248
- # TODO: Import Issue -- Is this related to the comment below in test_encode_all?
249
- # TypeError: nil value
250
- #encode_decode_test B(%w{ 05 00 }), OpenSSL::ASN1::Null.new(nil)
248
+ encode_decode_test B ( %w{ 05 00 } ) , OpenSSL ::ASN1 ::Null . new ( nil )
251
249
assert_raise ( OpenSSL ::ASN1 ::ASN1Error ) {
252
250
OpenSSL ::ASN1 . decode ( B ( %w{ 05 01 00 } ) )
253
251
}
@@ -384,13 +382,11 @@ def test_simple_to_der
384
382
385
383
def test_sequence
386
384
encode_decode_test B ( %w{ 30 00 } ) , OpenSSL ::ASN1 ::Sequence . new ( [ ] )
387
- # TODO: Import Issue
388
- # TypeError: nil value
389
- #encode_decode_test B(%w{ 30 07 05 00 30 00 04 01 00 }), OpenSSL::ASN1::Sequence.new([
390
- # OpenSSL::ASN1::Null.new(nil),
391
- # OpenSSL::ASN1::Sequence.new([]),
392
- # OpenSSL::ASN1::OctetString.new(B(%w{ 00 }))
393
- #])
385
+ encode_decode_test B ( %w{ 30 07 05 00 30 00 04 01 00 } ) , OpenSSL ::ASN1 ::Sequence . new ( [
386
+ OpenSSL ::ASN1 ::Null . new ( nil ) ,
387
+ OpenSSL ::ASN1 ::Sequence . new ( [ ] ) ,
388
+ OpenSSL ::ASN1 ::OctetString . new ( B ( %w{ 00 } ) )
389
+ ] )
394
390
395
391
expected = OpenSSL ::ASN1 ::Sequence . new ( [ OpenSSL ::ASN1 ::OctetString . new ( B ( %w{ 00 } ) ) ] )
396
392
expected . indefinite_length = true
You can’t perform that action at this time.
0 commit comments