Skip to content

Commit 8b724f0

Browse files
author
Daniele Vona
committed
Add context param in HTTPSConnection to support SSL unverified certificate.
1 parent bf07c1a commit 8b724f0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

python3/plesk_api_client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# Copyright 1999-2015. Parallels IP Holdings GmbH. All Rights Reserved.
22

33
import http.client
4+
import ssl
45

56
class PleskApiClient:
67

7-
def __init__(self, host, port = 8443, protocol = 'https'):
8+
def __init__(self, host, port = 8443, protocol = 'https', ssl_unverified = False):
89
self.host = host
910
self.port = port
1011
self.protocol = protocol
1112
self.secret_key = None
13+
self.ssl_unverified = ssl_unverified
1214

1315
def set_credentials(self, login, password):
1416
self.login = login
@@ -29,7 +31,10 @@ def request(self, request):
2931
headers["HTTP_AUTH_PASSWD"] = self.password
3032

3133
if 'https' == self.protocol:
32-
conn = http.client.HTTPSConnection(self.host, self.port)
34+
if self.ssl_unverified:
35+
conn = http.client.HTTPSConnection(self.host, self.port, context=ssl._create_unverified_context())
36+
else:
37+
conn = http.client.HTTPSConnection(self.host, self.port)
3338
else:
3439
conn = http.client.HTTPConnection(self.host, self.port)
3540

0 commit comments

Comments
 (0)