private function _resolvePathsToTarget(Certificate $target,
        CertificateBundle $intermediate = null): array
    {
        // array of possible paths
        $paths = array();
        // signed by certificate in the trust list
        foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
            // if target is self-signed, path consists of only
            // the target certificate
            if ($target->equals($issuer)) {
                $paths[] = array($target);
            } else {
                $paths[] = array($issuer, $target);
            }
        }
        if (isset($intermediate)) {
            // signed by intermediate certificate
            foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
                // intermediate certificate must not be self-signed
                if ($issuer->isSelfIssued()) {
                    continue;
                }
                // resolve paths to issuer
                $subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
                foreach ($subpaths as $path) {
                    $paths[] = array_merge($path, array($target));
                }
            }
        }
        return $paths;
    }
private function _resolvePathsToTarget(Certificate $target,
        CertificateBundle $intermediate = null): array
    {
        // array of possible paths
        $paths = array();
        // signed by certificate in the trust list
        foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
            // if target is self-signed, path consists of only
            // the target certificate
            if ($target->equals($issuer)) {
                $paths[] = array($target);
            } else {
                $paths[] = array($issuer, $target);
            }
        }
        if (isset($intermediate)) {
            // signed by intermediate certificate
            foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
                // intermediate certificate must not be self-signed
                if ($issuer->isSelfIssued()) {
                    continue;
                }
                // resolve paths to issuer
                $subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
                foreach ($subpaths as $path) {
                    $paths[] = array_merge($path, array($target));
                }
            }
        }
        return $paths;
    }
private function _resolvePathsToTarget ( Certificate $ target , CertificateBundle $ intermediate = null ) : array { // array of possible paths $ paths = array ( ) ; // signed by certificate in the trust list foreach ( $ this -> _findIssuers ( $ target , $ this -> _trustList ) as $ issuer ) { // if target is self-signed, path consists of only // the target certificate if ( $ target -> equals ( $ issuer ) ) { $ paths [ ] = array ( $ target ) ; } else { $ paths [ ] = array ( $ issuer , $ target ) ; } } if ( isset ( $ intermediate ) ) { // signed by intermediate certificate foreach ( $ this -> _findIssuers ( $ target , $ intermediate ) as $ issuer ) { // intermediate certificate must not be self-signed if ( $ issuer -> isSelfIssued ( ) ) { continue ; } // resolve paths to issuer $ subpaths = $ this -> _resolvePathsToTarget ( $ issuer , $ intermediate ) ; foreach ( $ subpaths as $ path ) { $ paths [ ] = array_merge ( $ path , array ( $ target ) ) ; } } } return $ paths ; }
Resolve all possible certification paths from any trust anchor to
the target certificate, using optional intermediate certificates.

Helper method for allPathsToTarget to be called recursively.

@todo Implement loop detection
@param Certificate $target
@param CertificateBundle $intermediate
@return array[] Array of arrays containing path certificates
Resolve all possible certification paths from any trust anchor to the target certificate using optional intermediate certificates .