| @@ 39-51 (lines=13) @@ | ||
| 36 | return self::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, |
|
| @@ 109-121 (lines=13) @@ | ||
| 106 | ||
| 107 | $fullCertificateChain = array_merge([$peerCertificate], $peerCertificateChain); |
|
| 108 | ||
| 109 | $certificates = array_map(function ($certificate) use ($remoteAddress) { |
|
| 110 | $certificateFields = openssl_x509_parse($certificate); |
|
| 111 | ||
| 112 | $fingerprint = openssl_x509_fingerprint($certificate); |
|
| 113 | $fingerprintSha256 = openssl_x509_fingerprint($certificate, 'sha256'); |
|
| 114 | ||
| 115 | return new SslCertificate( |
|
| 116 | $certificateFields, |
|
| 117 | $fingerprint, |
|
| 118 | $fingerprintSha256, |
|
| 119 | $remoteAddress |
|
| 120 | ); |
|
| 121 | }, $fullCertificateChain); |
|
| 122 | ||
| 123 | return array_unique($certificates); |
|
| 124 | } |
|