summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/mail/smtpconfig.py
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2013-09-17 15:43:01 -0400
committerKali Kaneko <kali@leap.se>2013-09-18 11:30:05 -0400
commit13f5d8fcee038f441dd91ef16dfdb254e1f0dd3f (patch)
tree2e7ddc1e889d420858bf1d9b28bb6570898b8bbe /src/leap/bitmask/services/mail/smtpconfig.py
parente475daff20a2278ad170cb1ebaf528e7ee4a1657 (diff)
download cert for SMTP if EIP did not do it.
includes refactor of common code for download of certificates and config files.
Diffstat (limited to 'src/leap/bitmask/services/mail/smtpconfig.py')
-rw-r--r--src/leap/bitmask/services/mail/smtpconfig.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py
index 20041c30..74c9bc94 100644
--- a/src/leap/bitmask/services/mail/smtpconfig.py
+++ b/src/leap/bitmask/services/mail/smtpconfig.py
@@ -14,25 +14,28 @@
#
# 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.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 +50,28 @@ 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(self.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