| @@ 99-111 (lines=13) @@ | ||
| 96 | ||
| 97 | $fullCertificateChain = array_merge([$peerCertificate], $peerCertificateChain); |
|
| 98 | ||
| 99 | $certificates = array_map(function ($certificate) use ($remoteAddress) { |
|
| 100 | $certificateFields = openssl_x509_parse($certificate); |
|
| 101 | ||
| 102 | $fingerprint = openssl_x509_fingerprint($certificate); |
|
| 103 | $fingerprintSha256 = openssl_x509_fingerprint($certificate, 'sha256'); |
|
| 104 | ||
| 105 | return new SslCertificate( |
|
| 106 | $certificateFields, |
|
| 107 | $fingerprint, |
|
| 108 | $fingerprintSha256, |
|
| 109 | $remoteAddress |
|
| 110 | ); |
|
| 111 | }, $fullCertificateChain); |
|
| 112 | ||
| 113 | return array_unique($certificates); |
|
| 114 | } |
|
| @@ 39-51 (lines=13) @@ | ||
| 36 | return $this->createFromString(file_get_contents($pathToCertificate)); |
|
| 37 | } |
|
| 38 | ||
| 39 | public static function createFromString(string $certificatePem): self |
|
| 40 | { |
|
| 41 | $certificateFields = openssl_x509_parse($certificatePem); |
|
| 42 | ||
| 43 | $fingerprint = openssl_x509_fingerprint($certificatePem); |
|
| 44 | $fingerprintSha256 = openssl_x509_fingerprint($certificatePem, 'sha256'); |
|
| 45 | ||
| 46 | return new self( |
|
| 47 | $certificateFields, |
|
| 48 | $fingerprint, |
|
| 49 | $fingerprintSha256 |
|
| 50 | ); |
|
| 51 | } |
|
| 52 | ||
| 53 | public function __construct( |
|
| 54 | array $rawCertificateFields, |
|