File tree Expand file tree Collapse file tree 1 file changed +8
-15
lines changed
webauthn-server-attestation/src/main/java/com/yubico/webauthn/attestation Expand file tree Collapse file tree 1 file changed +8
-15
lines changed Original file line number Diff line number Diff line change 2424
2525package com .yubico .webauthn .attestation ;
2626
27- import java . nio . ByteBuffer ;
27+ import com . yubico . internal . util . BinaryUtil ;
2828import java .security .cert .X509Certificate ;
2929import java .util .Optional ;
3030import lombok .experimental .UtilityClass ;
@@ -34,21 +34,14 @@ public class CertificateUtil {
3434 public static final String ID_FIDO_GEN_CE_SERNUM = "1.3.6.1.4.1.45724.1.1.2" ;
3535
3636 private static byte [] parseSerNum (byte [] bytes ) {
37- if (bytes != null ) {
38- ByteBuffer buffer = ByteBuffer .wrap (bytes );
39-
40- if (buffer .get () == (byte ) 0x04 && buffer .get () > 0 && buffer .get () == (byte ) 0x04 ) {
41-
42- byte length = buffer .get ();
43- byte [] serNumBytes = new byte [length ];
44- buffer .get (serNumBytes );
45-
46- return serNumBytes ;
47- }
37+ try {
38+ byte [] extensionValueContents = BinaryUtil .parseDerOctetString (bytes , 0 ).result ;
39+ byte [] sernumContents = BinaryUtil .parseDerOctetString (extensionValueContents , 0 ).result ;
40+ return sernumContents ;
41+ } catch (Exception e ) {
42+ throw new IllegalArgumentException (
43+ "X.509 extension 1.3.6.1.4.1.45724.1.1.2 (id-fido-gen-ce-sernum) is not valid." , e );
4844 }
49-
50- throw new IllegalArgumentException (
51- "X.509 extension 1.3.6.1.4.1.45724.1.1.2 (id-fido-gen-ce-sernum) is not valid." );
5245 }
5346
5447 public static Optional <byte []> parseFidoSerNumExtension (X509Certificate cert ) {
You can’t perform that action at this time.
0 commit comments