File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -96,14 +96,23 @@ protected function _createX5cChainFile() {
9696 if (\is_array ($ this ->_x5c_chain ) && \count ($ this ->_x5c_chain ) > 0 ) {
9797 foreach ($ this ->_x5c_chain as $ x5c ) {
9898 $ certInfo = \openssl_x509_parse ($ this ->_createCertificatePem ($ x5c ));
99- // check if issuer = subject (self signed)
99+
100+ // check if certificate is self signed
100101 if (\is_array ($ certInfo ) && \is_array ($ certInfo ['issuer ' ]) && \is_array ($ certInfo ['subject ' ])) {
101- $ selfSigned = true ;
102- foreach ($ certInfo ['issuer ' ] as $ k => $ v ) {
103- if ($ certInfo ['subject ' ][$ k ] !== $ v ) {
104- $ selfSigned = false ;
105- break ;
106- }
102+ $ selfSigned = false ;
103+
104+ $ subjectKeyIdentifier = $ certInfo ['extensions ' ]['subjectKeyIdentifier ' ] ?? null ;
105+ $ authorityKeyIdentifier = $ certInfo ['extensions ' ]['authorityKeyIdentifier ' ] ?? null ;
106+
107+ if ($ authorityKeyIdentifier && substr ($ authorityKeyIdentifier , 0 , 6 ) === 'keyid: ' ) {
108+ $ authorityKeyIdentifier = substr ($ authorityKeyIdentifier , 6 );
109+ }
110+ if ($ subjectKeyIdentifier && substr ($ subjectKeyIdentifier , 0 , 6 ) === 'keyid: ' ) {
111+ $ subjectKeyIdentifier = substr ($ subjectKeyIdentifier , 6 );
112+ }
113+
114+ if (($ subjectKeyIdentifier && !$ authorityKeyIdentifier ) || ($ authorityKeyIdentifier && $ authorityKeyIdentifier === $ subjectKeyIdentifier )) {
115+ $ selfSigned = true ;
107116 }
108117
109118 if (!$ selfSigned ) {
You can’t perform that action at this time.
0 commit comments