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