summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/services/mail
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2015-09-02 16:04:06 -0400
committerKali Kaneko <kali@leap.se>2015-09-21 16:59:36 -0400
commitce63b5a0277b3ff062d04a17af9e9a927b7d9b87 (patch)
tree35b30325c6e450d18e9a653fae4e83719df490e2 /src/leap/bitmask/services/mail
parent262a9a750a573ae6003ebf19d5a1867bc19d28c0 (diff)
[feature] retrieve specific smtp certificate. Closes: #4284
Diffstat (limited to 'src/leap/bitmask/services/mail')
-rw-r--r--src/leap/bitmask/services/mail/smtpbootstrapper.py6
-rw-r--r--src/leap/bitmask/services/mail/smtpconfig.py7
2 files changed, 9 insertions, 4 deletions
diff --git a/src/leap/bitmask/services/mail/smtpbootstrapper.py b/src/leap/bitmask/services/mail/smtpbootstrapper.py
index cd871803..a1b520ef 100644
--- a/src/leap/bitmask/services/mail/smtpbootstrapper.py
+++ b/src/leap/bitmask/services/mail/smtpbootstrapper.py
@@ -87,7 +87,7 @@ class SMTPBootstrapper(AbstractBootstrapper):
logger.debug("Using hostname %s for SMTP" % (hostname,))
client_cert_path = self._smtp_config.get_client_cert_path(
- self._provider_config, about_to_download=True)
+ self._userid, self._provider_config, about_to_download=True)
if not is_file(client_cert_path):
# For re-download if something is wrong with the cert
@@ -101,7 +101,7 @@ class SMTPBootstrapper(AbstractBootstrapper):
download_client_cert(self._provider_config,
client_cert_path,
- self._session)
+ self._session, kind="smtp")
def _start_smtp_service(self):
"""
@@ -117,7 +117,7 @@ class SMTPBootstrapper(AbstractBootstrapper):
host = hosts[hostname][self.IP_KEY].encode("utf-8")
port = hosts[hostname][self.PORT_KEY]
client_cert_path = self._smtp_config.get_client_cert_path(
- self._provider_config, about_to_download=True)
+ self._userid, self._provider_config, about_to_download=True)
from leap.mail.smtp import setup_smtp_gateway
diff --git a/src/leap/bitmask/services/mail/smtpconfig.py b/src/leap/bitmask/services/mail/smtpconfig.py
index 2d8de411..f78b3449 100644
--- a/src/leap/bitmask/services/mail/smtpconfig.py
+++ b/src/leap/bitmask/services/mail/smtpconfig.py
@@ -53,19 +53,24 @@ class SMTPConfig(ServiceConfig):
return self._safe_get_value("locations")
def get_client_cert_path(self,
+ userid,
providerconfig=None,
about_to_download=False):
"""
Returns the path to the certificate used by smtp
+ :param userid: the user id, in user@provider form
"""
+ leap_assert(userid, "Need an userid")
leap_assert(providerconfig, "We need a provider")
leap_assert_type(providerconfig, ProviderConfig)
+ username = userid.split("@")[0]
+
cert_path = os.path.join(get_path_prefix(),
"leap", "providers",
providerconfig.get_domain(),
- "keys", "client", "smtp.pem")
+ "keys", "client", "smtp_%s.pem" % username)
if not about_to_download:
leap_assert(os.path.exists(cert_path),