-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
combine params.tls and .tls_verify, support pinned certs
- Loading branch information
Showing
9 changed files
with
85 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,28 @@ | ||
import ssl | ||
|
||
class TLS: | ||
pass | ||
|
||
# tls without verification | ||
class TLSNoVerify(TLS): | ||
pass | ||
TLS_NOVERIFY = TLSNoVerify() | ||
|
||
# verify via CAs | ||
class TLSVerifyChain(TLS): | ||
pass | ||
TLS_VERIFYCHAIN = TLSVerifyChain() | ||
|
||
# verify by a pinned hash | ||
class TLSVerifyHash(TLSNoVerify): | ||
def __init__(self, sum: str): | ||
self.sum = sum.lower() | ||
class TLSVerifySHA512(TLSVerifyHash): | ||
pass | ||
|
||
def tls_context(verify: bool=True) -> ssl.SSLContext: | ||
return ssl.create_default_context() | ||
ctx = ssl.create_default_context() | ||
if not verify: | ||
ctx.check_hostname = False | ||
ctx.verify_mode = ssl.CERT_NONE | ||
return ctx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters