@@ -147,6 +147,10 @@ public function createCertificateBundle(): void {
147147 $ tmpPath = $ certPath . '.tmp ' . $ this ->random ->generate (10 , ISecureRandom::CHAR_DIGITS );
148148 $ fhCerts = $ this ->view ->fopen ($ tmpPath , 'w ' );
149149
150+ if (!is_resource ($ fhCerts )) {
151+ throw new \RuntimeException ('Unable to open file handler to create certificate bundle " ' . $ tmpPath . '". ' );
152+ }
153+
150154 // Write user certificates
151155 foreach ($ certs as $ cert ) {
152156 $ file = $ path . '/uploads/ ' . $ cert ->getName ();
@@ -238,7 +242,7 @@ public function getCertificateBundle(): string {
238242 */
239243 public function getAbsoluteBundlePath (): string {
240244 try {
241- if (! $ this ->bundlePath ) {
245+ if ($ this ->bundlePath === null ) {
242246 if (!$ this ->hasCertificates ()) {
243247 $ this ->bundlePath = \OC ::$ SERVERROOT . '/resources/config/ca-bundle.crt ' ;
244248 }
@@ -247,10 +251,16 @@ public function getAbsoluteBundlePath(): string {
247251 $ this ->createCertificateBundle ();
248252 }
249253
250- $ this ->bundlePath = $ this ->view ->getLocalFile ($ this ->getCertificateBundle ());
254+ $ certificateBundle = $ this ->getCertificateBundle ();
255+ $ this ->bundlePath = $ this ->view ->getLocalFile ($ certificateBundle ) ?: null ;
256+
257+ if ($ this ->bundlePath === null ) {
258+ throw new \RuntimeException ('Unable to get certificate bundle " ' . $ certificateBundle . '". ' );
259+ }
251260 }
252261 return $ this ->bundlePath ;
253262 } catch (\Exception $ e ) {
263+ $ this ->logger ->error ('Failed to get absolute bundle path. Fallback to default ca-bundle.crt ' , ['exception ' => $ e ]);
254264 return \OC ::$ SERVERROOT . '/resources/config/ca-bundle.crt ' ;
255265 }
256266 }
0 commit comments