File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
app/models/concerns/equipment/stir_shaken Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,21 @@ def format_tn_auth_list(certificate)
5151 ext = certificate . extensions . find { |e | e . oid == TN_AUTH_LIST_OID }
5252 return [ ] if ext . nil?
5353
54- tn_auth_seq = OpenSSL :: ASN1 . decode ( OpenSSL :: ASN1 . decode ( ext . value_der ) . value )
54+ tn_auth_seq = decode_tn_auth_list ( ext )
5555 entries = tn_auth_seq . value . map { |entry | format_tn_auth_entry ( entry ) }
5656 [ 'TNAuthList:' ] + entries . map { |e | " #{ e } " }
5757 rescue OpenSSL ::ASN1 ::ASN1Error
5858 [ 'TNAuthList: unable to decode' ]
5959 end
6060
61+ def decode_tn_auth_list ( ext )
62+ decoded = OpenSSL ::ASN1 . decode ( ext . value_der )
63+ # value_der may or may not include OCTET STRING wrapper depending on
64+ # how the extension was encoded. If first decode returns an OctetString,
65+ # we need a second decode to get the actual TNAuthList sequence.
66+ decoded . tag == OpenSSL ::ASN1 ::OCTET_STRING ? OpenSSL ::ASN1 . decode ( decoded . value ) : decoded
67+ end
68+
6169 def format_tn_auth_entry ( entry )
6270 case entry . tag
6371 when 0
Original file line number Diff line number Diff line change @@ -94,9 +94,13 @@ def build_tn_auth_list_extension(entries)
9494 end
9595 end
9696 tn_auth_list = OpenSSL ::ASN1 ::Sequence . new ( tn_entries )
97- OpenSSL ::X509 ::Extension . new (
98- '1.3.6.1.5.5.7.1.26' ,
99- OpenSSL ::ASN1 ::OctetString . new ( tn_auth_list . to_der )
100- )
97+ # Build extension from raw DER to match real certificate encoding.
98+ # This ensures value_der returns the TNAuthList sequence directly
99+ # (without extra OCTET STRING wrapper).
100+ ext_der = OpenSSL ::ASN1 ::Sequence . new ( [
101+ OpenSSL ::ASN1 ::ObjectId . new ( '1.3.6.1.5.5.7.1.26' ) ,
102+ OpenSSL ::ASN1 ::OctetString . new ( tn_auth_list . to_der )
103+ ] )
104+ OpenSSL ::X509 ::Extension . new ( ext_der . to_der )
101105 end
102106end
You can’t perform that action at this time.
0 commit comments