@@ -25,29 +25,38 @@ public static function convert(Anchor $protobufAnchor)
25
25
$ anchorSubType = $ protobufAnchor ->getSubType ();
26
26
$ yotiSignedTimeStamp = self ::convertToYotiSignedTimestamp ($ protobufAnchor );
27
27
$ X509CertsList = self ::convertCertsListToX509 ($ X509 , $ protobufAnchor ->getOriginServerCerts ());
28
+ $ anchorTypesMap = self ::getAnchorTypesMap ();
28
29
29
30
foreach ($ X509CertsList as $ certX509Obj ) {
30
31
$ certExtArr = $ certX509Obj ->tbsCertificate ->extensions ;
31
32
32
- if (count ($ certExtArr ) > 1 ) {
33
- $ oid = $ certExtArr [1 ]->extnId ;
34
- $ anchorType = self ::getAnchorTypeByOid ($ oid );
35
- $ extEncodedValue = $ certExtArr [1 ]->extnValue ;
36
-
37
- if ($ decodedAnchorValue = self ::decodeAnchorValue ($ ASN1 , $ X509 , $ extEncodedValue )) {
38
- $ yotiAnchor = self ::createYotiAnchor (
39
- $ decodedAnchorValue ,
40
- $ anchorType ,
41
- $ anchorSubType ,
42
- $ yotiSignedTimeStamp ,
43
- $ X509CertsList
44
- );
45
- $ anchorMap = [
46
- 'oid ' => $ oid ,
47
- 'yoti_anchor ' => $ yotiAnchor
48
- ];
49
- // We are only looking for one YotiAnchor from protobufAnchor
50
- break ;
33
+ foreach ($ anchorTypesMap as $ oid => $ anchorType )
34
+ {
35
+ foreach ($ certExtArr as $ extObj ) {
36
+ $ extRaw = (array ) $ extObj ;
37
+ $ oidFound = array_search ($ oid , $ extRaw , TRUE );
38
+ if ($ oidFound !== FALSE ) {
39
+ $ extEncodedValue = $ extRaw ['extnValue ' ];
40
+
41
+ if (
42
+ is_string ($ extEncodedValue )
43
+ && ($ decodedAnchorValue = self ::decodeAnchorValue ($ ASN1 , $ X509 , $ extEncodedValue ))
44
+ ) {
45
+ $ yotiAnchor = self ::createYotiAnchor (
46
+ $ decodedAnchorValue ,
47
+ $ anchorType ,
48
+ $ anchorSubType ,
49
+ $ yotiSignedTimeStamp ,
50
+ $ X509CertsList
51
+ );
52
+ $ anchorMap = [
53
+ 'oid ' => $ oid ,
54
+ 'yoti_anchor ' => $ yotiAnchor
55
+ ];
56
+ // We are only looking for one YotiAnchor from protobufAnchor
57
+ break ;
58
+ }
59
+ }
51
60
}
52
61
}
53
62
}
0 commit comments