summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/mail/smtpconfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/bitmask/services/mail/smtpconfig.py')
-rw-r--r--src/leap/bitmask/services/mail/smtpconfig.py34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py
index 20041c30..09f90314 100644
--- a/src/leap/bitmask/services/mail/smtpconfig.py
+++ b/src/leap/bitmask/services/mail/smtpconfig.py
@@ -14,25 +14,29 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
"""
SMTP configuration
"""
import logging
+import os
+from leap.bitmask.config.providerconfig import ProviderConfig
+from leap.bitmask.services import ServiceConfig
from leap.bitmask.services.mail.smtpspec import get_schema
-from leap.common.config.baseconfig import BaseConfig
+from leap.bitmask.util import get_path_prefix
+from leap.common.check import leap_assert, leap_assert_type
logger = logging.getLogger(__name__)
-class SMTPConfig(BaseConfig):
+class SMTPConfig(ServiceConfig):
"""
SMTP configuration abstraction class
"""
+ _service_name = "smtp"
def __init__(self):
- BaseConfig.__init__(self)
+ ServiceConfig.__init__(self)
def _get_schema(self):
"""
@@ -47,3 +51,25 @@ class SMTPConfig(BaseConfig):
def get_locations(self):
return self._safe_get_value("locations")
+
+ def get_client_cert_path(self,
+ providerconfig=None,
+ about_to_download=False):
+ """
+ Returns the path to the certificate used by smtp
+ """
+
+ leap_assert(providerconfig, "We need a provider")
+ leap_assert_type(providerconfig, ProviderConfig)
+
+ cert_path = os.path.join(get_path_prefix(),
+ "leap", "providers",
+ providerconfig.get_domain(),
+ "keys", "client", "smtp.pem")
+
+ if not about_to_download:
+ leap_assert(os.path.exists(cert_path),
+ "You need to download the certificate first")
+ logger.debug("Using SMTP cert %s" % (cert_path,))
+
+ return cert_path