Conditions | 5 |
Paths | 4 |
Total Lines | 18 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
28 | public function loadKey($type) |
||
29 | { |
||
30 | $path = $this->getKeyPath($type); |
||
31 | $encryptedKey = file_get_contents($path); |
||
32 | $key = call_user_func_array(sprintf('openssl_pkey_get_%s', $type), self::TYPE_PRIVATE == $type ? [$encryptedKey, $this->getPassPhrase()] : [$encryptedKey]); |
||
33 | if (!$key) { |
||
34 | $sslError = ''; |
||
35 | while ($msg = trim(openssl_error_string(), " \n\r\t\0\x0B\"")) { |
||
36 | if ('error:' === substr($msg, 0, 6)) { |
||
37 | $msg = substr($msg, 6); |
||
38 | } |
||
39 | $sslError .= "\n ".$msg; |
||
40 | } |
||
41 | |||
42 | throw new RuntimeException(sprintf('Failed to load %s key "%s": %s', $type, $path, $sslError)); |
||
43 | } |
||
44 | |||
45 | return $key; |
||
46 | } |
||
48 |