{@inhericDoc}
@see \MyArtJaub\Webtrees\Module\Certificates\Model\CertificateProviderInterface::getCertificatesList()
513094
public function getCertificatesList($selCity){
    
        $selCity = Functions::encodeUtf8ToFileSystem($selCity);
    
        $certdir = $this->getRealCertificatesDirectory();
        $tabCertif= array();
    
        if(is_dir($certdir.$selCity)){
            $dir=opendir($certdir.$selCity);
            while($entry = readdir($dir)){
                if($entry!='.' && $entry!='..' && !is_dir($certdir.$entry.'/')){
                    $path = Functions::encodeFileSystemToUtf8($selCity.'/'.$entry);
                    $certificate = new Certificate($path, $this->tree, $this);
                    if(Functions::isImageTypeSupported($certificate->extension())){
                        $tabCertif[] = 	$certificate;
                    }
                }
            }
        }
        return $tabCertif;
    }
165571
public function getThumbprint()
    {
        $resource = openssl_x509_read($this->certificate);
        $thumbprint = null;
        $output = null;
        
        $result = openssl_x509_export($resource, $output);
        if ($result !== false) {
            $output = str_replace('-----BEGIN CERTIFICATE-----', '', $output);
            $output = str_replace('-----END CERTIFICATE-----', '', $output);
            $output = base64_decode($output);
            $thumbprint = sha1($output);
        }
        
        return $thumbprint;
    }
772655
public function getJwtVerificationKeys()
    {
        $factory = $this->getRequestFactory();
        $request = $factory->getRequestWithOptions('get', 'https://login.windows.net/common/discovery/keys', []);

        $response = $this->getParsedResponse($request);

        $keys = [];
        foreach ($response['keys'] as $i => $keyinfo) {
            if (isset($keyinfo['x5c']) && is_array($keyinfo['x5c'])) {
                foreach ($keyinfo['x5c'] as $encodedkey) {
                    $cert =
                        '-----BEGIN CERTIFICATE-----' . PHP_EOL
                        . chunk_split($encodedkey, 64,  PHP_EOL)
                        . '-----END CERTIFICATE-----' . PHP_EOL;

                    $cert_object = openssl_x509_read($cert);

                    if ($cert_object === false) {
                        throw new \RuntimeException('An attempt to read ' . $encodedkey . ' as a certificate failed.');
                    }

                    $pkey_object = openssl_pkey_get_public($cert_object);

                    if ($pkey_object === false) {
                        throw new \RuntimeException('An attempt to read a public key from a ' . $encodedkey . ' certificate failed.');
                    }

                    $pkey_array = openssl_pkey_get_details($pkey_object);

                    if ($pkey_array === false) {
                        throw new \RuntimeException('An attempt to get a public key as an array from a ' . $encodedkey . ' certificate failed.');
                    }

                    $publicKey = $pkey_array ['key'];

                    $keys[$keyinfo['kid']] = $publicKey;
                }
            }
        }

        return $keys;
    }
616158
public function getLicenseUris()
    {
        $result             = array();
        $mapper             = $this->getMapper();
        $licenseUrlPatterns = array(
            '/^cc-(by-sa|by-nd|by-nc|by-nc-sa|by-nc-nd)-(\d+\.\d+)$/i' => function ( $matches ) {
                return 'http://creativecommons.org/licenses/' . strtolower( $matches[1] ) . '/' . $matches[2];
            },
            '/^cc0-(\d+\.\d+)$/i'           => 'http://creativecommons.org/publicdomain/zero/$1',
            '/^Apache-(\d+\.\d+)$/i'        => 'http://www.apache.org/licenses/LICENSE-$1',
            '/^Artistic-(\d+)\.(\d+)$/i'    => 'http://www.perlfoundation.org/artistic_license_$1_$2',
            '/^GPL-(\d+\.\d+)\+?$/i'        => 'http://www.gnu.org/licenses/gpl-$1-standalone.html',
            '/^LGPL-(\d+\.\d+)\+?$/i'       => 'http://www.gnu.org/licenses/lgpl-$1-standalone.html',
            '/^MIT$/i'                      => 'http://opensource.org/licenses/MIT',
            '/^proprietary/i'               => '',
            '/^([^\(].*)$/i'                => function ( $matches ) use ( $mapper ) {
                static $uris = array(
                    'http://opensource.org/licenses/%s',
                    'http://spdx.org/licenses/%s'
                );

                if ( empty( $mapper ) )
                {
                    return '';
                }

                foreach ( $uris as $uriPattern )
                {
                    $uri = vsprintf( $uriPattern, $matches );

                    if ( $mapper->getHttpClient( $uri )
                                ->send()
                                ->isOk() )
                    {
                        return $uri;
                    }
                }

                return '';
            },
        );

        foreach ( $this->license as $license )
        {
            foreach ( $licenseUrlPatterns as $pattern => $replacement )
            {
                $count  = 0;
                $method = is_callable( $replacement ) ? 'preg_replace_callback' : 'preg_replace';
                $uri    = $method( $pattern, $replacement, $license, 1, $count );

                if ( $count && $uri )
                {
                    $result[$license] = $uri;
                    continue 2;
                }
            }

            $result[$license] = '';
        }

        return $result;
    }
34375
function loadCSR($csr, $mode = self::FORMAT_AUTO_DETECT)
    {
        if (is_array($csr) && isset($csr['certificationRequestInfo'])) {
            unset($this->currentCert);
            unset($this->currentKeyIdentifier);
            unset($this->signatureSubject);
            $this->dn = $csr['certificationRequestInfo']['subject'];
            if (!isset($this->dn)) {
                return false;
            }

            $this->currentCert = $csr;
            return $csr;
        }

        // see http://tools.ietf.org/html/rfc2986

        $asn1 = new ASN1();

        if ($mode != self::FORMAT_DER) {
            $newcsr = $this->_extractBER($csr);
            if ($mode == self::FORMAT_PEM && $csr == $newcsr) {
                return false;
            }
            $csr = $newcsr;
        }
        $orig = $csr;

        if ($csr === false) {
            $this->currentCert = false;
            return false;
        }

        $asn1->loadOIDs($this->oids);
        $decoded = $asn1->decodeBER($csr);

        if (empty($decoded)) {
            $this->currentCert = false;
            return false;
        }

        $csr = $asn1->asn1map($decoded[0], $this->CertificationRequest);
        if (!isset($csr) || $csr === false) {
            $this->currentCert = false;
            return false;
        }

        $this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
        $this->_mapInDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);

        $this->dn = $csr['certificationRequestInfo']['subject'];

        $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);

        $algorithm = &$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'];
        $key = &$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'];
        $key = $this->_reformatKey($algorithm, $key);

        switch ($algorithm) {
            case 'rsaEncryption':
                $this->publicKey = new RSA();
                $this->publicKey->loadKey($key);
                $this->publicKey->setPublicKey();
                break;
            default:
                $this->publicKey = null;
        }

        $this->currentKeyIdentifier = null;
        $this->currentCert = $csr;

        return $csr;
    }
834981
protected function retrieveCertificate($certificateId)
    {
        // Retrieve from cache if a cache handler has been set.
        $cacheKey = 'store-receipt-validate.windowsstore.' . $certificateId;
        $certificate = $this->cache !== null ? $this->cache->get($cacheKey) : null;

        if ($certificate === null) {
            $maxCertificateSize = 10000;

            // We are attempting to retrieve the following url. The getAppReceiptAsync website at
            // http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.store.currentapp.getappreceiptasync.aspx
            // lists the following format for the certificate url.
            $certificateUrl = '/fwlink/?LinkId=246509&cid=' . $certificateId;

            // Make an HTTP GET request for the certificate.
            $client = new \GuzzleHttp\Client(['base_uri' => 'https://go.microsoft.com']);
            $response = $client->request('GET', $certificateUrl);

            // Retrieve the certificate out of the response.
            $certificate = $response->getBody();

            // Write back to cache.
            if ($this->cache !== null) {
                $this->cache->put($cacheKey, $certificate, 3600);
            }
        }

        return openssl_x509_read($certificate);
    }
429054
private static function _getCertKeyId(Certificate $cert): string
    {
        $exts = $cert->tbsCertificate()->extensions();
        if ($exts->hasSubjectKeyIdentifier()) {
            return $exts->subjectKeyIdentifier()->keyIdentifier();
        }
        return $cert->tbsCertificate()
            ->subjectPublicKeyInfo()
            ->keyIdentifier();
    }
1339064
public function endEntityCertificate(): Certificate
    {
        if (!count($this->_certificates)) {
            throw new \LogicException("No certificates.");
        }
        return $this->_certificates[count($this->_certificates) - 1];
    }
917783
function loadCSR($csr, $mode = FILE_X509_FORMAT_AUTO_DETECT)
    {
        if (is_array($csr) && isset($csr['certificationRequestInfo'])) {
            unset($this->currentCert);
            unset($this->currentKeyIdentifier);
            unset($this->signatureSubject);
            $this->dn = $csr['certificationRequestInfo']['subject'];
            if (!isset($this->dn)) {
                return false;
            }

            $this->currentCert = $csr;
            return $csr;
        }

        // see http://tools.ietf.org/html/rfc2986

        $asn1 = new File_ASN1();

        if ($mode != FILE_X509_FORMAT_DER) {
            $newcsr = $this->_extractBER($csr);
            if ($mode == FILE_X509_FORMAT_PEM && $csr == $newcsr) {
                return false;
            }
            $csr = $newcsr;
        }
        $orig = $csr;

        if ($csr === false) {
            $this->currentCert = false;
            return false;
        }

        $asn1->loadOIDs($this->oids);
        $decoded = $asn1->decodeBER($csr);

        if (empty($decoded)) {
            $this->currentCert = false;
            return false;
        }

        $csr = $asn1->asn1map($decoded[0], $this->CertificationRequest);
        if (!isset($csr) || $csr === false) {
            $this->currentCert = false;
            return false;
        }

        $this->_mapInAttributes($csr, 'certificationRequestInfo/attributes', $asn1);
        $this->_mapInDNs($csr, 'certificationRequestInfo/subject/rdnSequence', $asn1);

        $this->dn = $csr['certificationRequestInfo']['subject'];

        $this->signatureSubject = substr($orig, $decoded[0]['content'][0]['start'], $decoded[0]['content'][0]['length']);

        $algorithm = &$csr['certificationRequestInfo']['subjectPKInfo']['algorithm']['algorithm'];
        $key = &$csr['certificationRequestInfo']['subjectPKInfo']['subjectPublicKey'];
        $key = $this->_reformatKey($algorithm, $key);

        switch ($algorithm) {
            case 'rsaEncryption':
                if (!class_exists('Crypt_RSA')) {
                    include_once 'Crypt/RSA.php';
                }
                $this->publicKey = new Crypt_RSA();
                $this->publicKey->loadKey($key);
                $this->publicKey->setPublicKey();
                break;
            default:
                $this->publicKey = null;
        }

        $this->currentKeyIdentifier = null;
        $this->currentCert = $csr;

        return $csr;
    }
711846
protected function getCertificates() {
        if (!$this->_certificates) {
            $this->_certificates = new CertificateList($this->version, $this->solution['sid']);
        }

        return $this->_certificates;
    }
74621
@Override
	public Certificate engineGetCertificate(String s) {
		ResourceTrustAnchor trustAnchor = getCertificateEntry(s);
		if (trustAnchor != null) {
			try {
				return trustAnchor.getTrustAnchor().getTrustedCert();
			} catch (ResourceStoreException e) {
				return null;
			}
		}
		return null;
	}
863375
public function getCertificate($clean = false)
    {
        if ($clean) {
            return trim(str_replace(
                ['-----BEGIN CERTIFICATE-----', '-----END CERTIFICATE-----'],
                '',
                $this->certs['cert']
            ));
        } else {
            return $this->certs['cert'];
        }
    }
1115602
public function trustAnchorCertificate(): Certificate
    {
        if (!count($this->_certs)) {
            throw new \LogicException("No certificates.");
        }
        return $this->_certs[count($this->_certs) - 1];
    }
974509
@Override
	public Certificate[] engineGetCertificateChain(String s) {
		CredentialWrapper credential = getKeyEntry(s);
		X509Certificate[] chain = new X509Certificate[0];
		if (credential != null) {
			try {
				chain = credential.getCredential().getCertificateChain();
			} catch (ResourceStoreException e) {
				logger.warn(e.getMessage(), e);
				chain = null;
			}
		}
		return chain;
	}
371303
public static String getIssuedBy(final X509Certificate certificate)
	{
		final X500Principal issuedByPrincipal = certificate.getSubjectX500Principal();
		final String issuedBy = issuedByPrincipal.getName();
		return issuedBy;
	}
1756
protected function getCertificateIssuerByAlias(Certificate $cert, $alias) {
        foreach ($cert->issuer as $issuer) {
            if (isset($issuer['alias'], $issuer['value']) && $issuer['alias'] === $alias) {
                return $issuer['value'];
            }
        }

        return false;
    }
1322031
public X509CRLEntry getRevokedCertificate(X509Certificate cert) {
        if (revokedMap.isEmpty()) {
            return null;
        }
        X509IssuerSerial issuerSerial = new X509IssuerSerial(cert);
        return revokedMap.get(issuerSerial);
    }