diff --git a/src/SamlService.php b/src/SamlService.php
index bfac06e..f1e956c 100644
--- a/src/SamlService.php
+++ b/src/SamlService.php
@@ -400,7 +400,7 @@ class SamlService {
     // complicated validation like checking whether the cert/key files exist.
     $sp_cert = '';
     $sp_key = '';
-    $cert_folder = $config->get('sp_cert_folder');
+    $cert_folder = $config->get('sp_cert_folder' && !defined('ONELOGIN_CUSTOMPATH'));
     if ($cert_folder) {
       // Set the folder so the Simple SAML toolkit knows where to look.
       define('ONELOGIN_CUSTOMPATH', "$cert_folder/");
