|
34 | 34 | namespace OC\Files\Storage; |
35 | 35 |
|
36 | 36 | use Exception; |
37 | | -use GuzzleHttp\Exception\RequestException; |
38 | 37 | use Icewind\Streams\CallbackWrapper; |
39 | 38 | use Icewind\Streams\IteratorDirectory; |
40 | 39 | use OC\Files\Filesystem; |
|
45 | 44 | use OCP\Files\ForbiddenException; |
46 | 45 | use OCP\Files\StorageInvalidException; |
47 | 46 | use OCP\Files\StorageNotAvailableException; |
| 47 | +use OCP\Http\Client\IClientService; |
| 48 | +use OCP\ICertificateManager; |
48 | 49 | use OCP\ILogger; |
49 | 50 | use OCP\Util; |
50 | 51 | use Psr\Http\Message\ResponseInterface; |
@@ -79,8 +80,10 @@ class DAV extends Common { |
79 | 80 | protected $client; |
80 | 81 | /** @var ArrayCache */ |
81 | 82 | protected $statCache; |
82 | | - /** @var \OCP\Http\Client\IClientService */ |
| 83 | + /** @var IClientService */ |
83 | 84 | protected $httpClientService; |
| 85 | + /** @var ICertificateManager */ |
| 86 | + protected $certManager; |
84 | 87 |
|
85 | 88 | /** |
86 | 89 | * @param array $params |
@@ -111,13 +114,9 @@ public function __construct($params) { |
111 | 114 | } |
112 | 115 | if ($this->secure === true) { |
113 | 116 | // inject mock for testing |
114 | | - $certManager = \OC::$server->getCertificateManager(); |
115 | | - if (is_null($certManager)) { //no user |
116 | | - $certManager = \OC::$server->getCertificateManager(null); |
117 | | - } |
118 | | - $certPath = $certManager->getAbsoluteBundlePath(); |
119 | | - if (file_exists($certPath)) { |
120 | | - $this->certPath = $certPath; |
| 117 | + $this->certManager = \OC::$server->getCertificateManager(); |
| 118 | + if (is_null($this->certManager)) { //no user |
| 119 | + $this->certManager = \OC::$server->getCertificateManager(null); |
121 | 120 | } |
122 | 121 | } |
123 | 122 | $this->root = $params['root'] ?? '/'; |
@@ -150,8 +149,15 @@ protected function init() { |
150 | 149 |
|
151 | 150 | $this->client = new Client($settings); |
152 | 151 | $this->client->setThrowExceptions(true); |
153 | | - if ($this->secure === true && $this->certPath) { |
154 | | - $this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath); |
| 152 | + |
| 153 | + if($this->secure === true) { |
| 154 | + $certPath = $this->certManager->getAbsoluteBundlePath(); |
| 155 | + if (file_exists($certPath)) { |
| 156 | + $this->certPath = $certPath; |
| 157 | + } |
| 158 | + if ($this->certPath) { |
| 159 | + $this->client->addCurlSetting(CURLOPT_CAINFO, $this->certPath); |
| 160 | + } |
155 | 161 | } |
156 | 162 | } |
157 | 163 |
|
|
0 commit comments