Skip to content

Commit 3b28b63

Browse files
committed
Added possibility of running exchangelib with older certificates and versions
1 parent fe8b462 commit 3b28b63

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

outlook_owa/1.0.0/Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ RUN apk update && \
77
# We're going to stage away all of the bloat from the build tools so lets create a builder stage
88

99
FROM base as builder
10-
RUN apk add --no-cache build-base gcc musl-dev python3-dev libffi-dev libxml2-dev libxslt-dev alpine-sdk openssl-dev libc-dev
10+
RUN apk add --no-cache build-base gcc musl-dev python3-dev libffi-dev libxml2-dev libxslt-dev alpine-sdk openssl-dev libc-dev ca-certificates
1111
RUN pip install --no-cache-dir -U pip && \
1212
pip wheel --no-cache-dir --wheel-dir=/root/lxml_wheel lxml
1313

@@ -32,6 +32,11 @@ RUN python -OO -m pip install --no-cache --no-index --find-links=/root/lxml_whee
3232
COPY --from=builder /install /usr/local
3333
COPY src /app
3434

35+
## Ensuring we can handle OLD exchange servers
36+
RUN echo "MinProtocol = TLSv1/" >> /etc/ssl/openssl.cnf
37+
run echo "CipherString = DEFAULT@SECLEVEL=1/" >> /etc/ssl/openssl.cnf
38+
RUN cat /etc/ssl/openssl.cnf
39+
3540
# Finally, lets run our app!
3641
WORKDIR /app
3742
CMD python app.py --log-level DEBUG

outlook_owa/1.0.0/src/app.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@
2222
from exchangelib.protocol import BaseProtocol, NoVerifyHTTPAdapter
2323
from walkoff_app_sdk.app_base import AppBase
2424

25+
import requests
26+
from urllib.parse import urlparse
27+
28+
class RootCAAdapter(requests.adapters.HTTPAdapter):
29+
"""
30+
An HTTP adapter that uses a custom root CA certificate at a hard coded
31+
location.
32+
"""
33+
34+
def cert_verify(self, conn, url, verify, cert):
35+
#cert_file = {
36+
# 'example.com': '/path/to/example.com.crt',
37+
# 'mail.internal': '/path/to/mail.internal.crt',
38+
#}[urlparse(url).hostname]
39+
#super().cert_verify(conn=conn, url=url, verify=cert_file, cert=cert)
40+
41+
super().cert_verify(conn=conn, url=url, verify=False, cert=cert)
2542

2643
def default(o):
2744
"""helpers to store item in json
@@ -55,8 +72,10 @@ def authenticate(self, username, password, server, build, account, verifyssl):
5572
"""
5673
Authenticates to Exchange server
5774
"""
75+
76+
BaseProtocol.USERAGENT = "Shuffle Automation"
5877
if not verifyssl or verifyssl.lower().strip() == "false":
59-
BaseProtocol.HTTP_ADAPTER_CLS = NoVerifyHTTPAdapter
78+
BaseProtocol.HTTP_ADAPTER_CLS = RootCAAdapter
6079

6180
processed_build = None
6281
if type(build) == str:

0 commit comments

Comments
 (0)