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 24
24
25
25
package com .yubico .webauthn .attestation ;
26
26
27
- import java . nio . ByteBuffer ;
27
+ import com . yubico . internal . util . BinaryUtil ;
28
28
import java .security .cert .X509Certificate ;
29
29
import java .util .Optional ;
30
30
import lombok .experimental .UtilityClass ;
@@ -34,21 +34,14 @@ public class CertificateUtil {
34
34
public static final String ID_FIDO_GEN_CE_SERNUM = "1.3.6.1.4.1.45724.1.1.2" ;
35
35
36
36
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 );
48
44
}
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." );
52
45
}
53
46
54
47
public static Optional <byte []> parseFidoSerNumExtension (X509Certificate cert ) {
You can’t perform that action at this time.
0 commit comments