This repository has been archived by the owner on Jul 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a new client_certs endpoint config option
requires whitelisted TLS client certificates for connections to the endpoint except to health/log_check handlers closes #498
- Loading branch information
Showing
16 changed files
with
573 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
[report] | ||
omit = *noseplugin* | ||
omit = | ||
*noseplugin* | ||
autopush/tests/certs/makecerts.py | ||
show_missing = true |
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
Empty file.
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBA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EjAQBgNVBAMMCWxvY2FsaG9zdDEVMBMGA1UECgwMTW96 | ||
aWxsYSBUZXN0MSIwIAYDVQQLDBlBdXRvcHVzaCBUZXN0IGNsaWVudDEucGVtMSQw | ||
IgYJKoZIhvcNAQkBFhVvdHRvLnB1c2hAZXhhbXBsZS5jb20wggEiMA0GCSqGSIb3 | ||
DQEBAQUAA4IBDwAwggEKAoIBAQDP2gdtxnN8cUyJIx9nR3AG0DANs5jkhogfa23w | ||
iWtwHsRlACKPEtJ4ScKsofmshwf0EsC+k7jO7qOcCOscgWtjASbNBGx4lY35dOTv | ||
M3SlTnPLMbU1rOVYuGYo8l8mE9P6g63pIQPSRp5PuQwPJVLopVlsM37F15KXrOw5 | ||
5+djPG76sjgLLZgLGTmVf6y4/JFgapKhktdA6W1pzwM+dzLXFdP5P6OGp2QhFzkt | ||
q4zhMnh6PwuOHjdLK+qD6Po1pPMHoSvXdUegQJXzqOO5sxstEVhnGUcNw47jikXS | ||
pFRio3CFrvm4gFgWsiIz9H02S8520ksbuzs5462Ie9HU0OvfAgMBAAGjGDAWMBQG | ||
A1UdEQQNMAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQUFAAOCAQEAq49K5htZ3Sw9 | ||
osT3CcKGS7m7r4FuvpL0gzE6ZDMElMK4q1u7M/DJKsXpINUqjT6cYwIJZyl02pmO | ||
HMwuImdCWpuWSE0lUyMjVSOXAGBkkcJiVE3iP9tGH1kcCTLKoY2Ajc8w65HNxRR7 | ||
edSprTDay4Zt2ay6AG4pYl8uGN5HuvgRzyjFPjVcye4ZfF3TaJRZAMl9lJSI1qMl | ||
DSziBbcjkx7N4TbMe8m01YYA1HmX2ZIckqEiTa05d1H548p5Dbw6GhoM/MzbEUeB | ||
s9/XlKoFQPVADqrd6yJcTGi6mMnuKMPkUhjPjzB4ah0m4gL0oB8E/TEs7yPAYPtw | ||
g17mJupYMw== | ||
-----END CERTIFICATE----- |
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 |
---|---|---|
@@ -0,0 +1,52 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDgoFA4pkilcycS | ||
P1q8Dfd8PSTYvabFITo4Qu3aDSezhw6WnoEPSO+O2Bd/GAAmoLzmMcHPdRUsUhp7 | ||
RIuSNnd6+g6ulXyf9BFcNclBmdIhvUAvVxy4/fBoJ0or8eNgETRRHj19j7S0tAUt | ||
oSAVW1XniSS+qX11kGsLqk6qIUl2v+p9j6GVdk1DkMO/xat2qdGpPcleexz1LD3o | ||
Tqs2rE8hdFlbJXE5K7jN7miej1cnEb+BV99N7P/3RBwkQdAfNYyzueY/UsfCaieF | ||
892+yo7eNA8qMZxWs86f7IjZAXJaO9sgg6YBCP+J0Oed83nc48Jq6LnCsNC9U7l5 | ||
k/UPbywZAgMBAAECggEAHXkLbZNr3sGQM9W6Owh+G4AOUJ35vs3QTMeDW+Pz/JtQ | ||
77RWbMH+JLj3xEZK5saaYn3O10CeiZUwQlJJGeMppCohOQkGNBqbGIU6JfBf4Otq | ||
+4srip5PJ+tX0RJI6jb3rVkRamMrq7YfI9CLXCIC0IFvH9EvU/iiAwLSlYIOmJTw | ||
6e96Um5eIR2NjEJk2Mlv8HpJ0Ai09gDttnYFyGMUa1USGX4SeqViRN/6mb2zqvdB | ||
OCrwhYwuPsA+WSHISKuj8xHusDCuxSTKCpYv08r/E1fMywYPP6BEp/IkrQfc6Ajv | ||
23CJ41rNGxg3SGi1O4v1ADygUNweb44eSZyDDkyZAQKBgQDyV0U/WdRXKhk5ZTil | ||
GWuseAt7V6UvqTHA0q7CBdDT+0ICospcENLOIul6ER16rDdAC2qeVrbReKYqska6 | ||
uVQq8513lvnt9fQwdgdH5kwSkEp4Ci0G6pnxAaJawJS3X5MdftLR2foHAaDsd59i | ||
6qFL/IJW+YV25epJ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KindazBzp44KVD/AAU | ||
xltE1FyPs2NVzf6NiEqXOLXX47kM7CByrabpo8nfUx1w79FscHP7DfjDZZIM0qT3 | ||
Gmi/Of1Z | ||
-----END CERTIFICATE----- |
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# encoding: utf-8 | ||
|
||
import uuid | ||
from inspect import getsource | ||
|
||
from OpenSSL.crypto import ( | ||
FILETYPE_PEM, PKey, TYPE_RSA, X509, X509Extension, | ||
dump_certificate, dump_privatekey) | ||
|
||
SHABREAK = 51 | ||
|
||
|
||
def make_cert(filename, cacert=None, cakey=None): | ||
key = PKey() | ||
key.generate_key(TYPE_RSA, 2048) | ||
|
||
cert = X509() | ||
subject = cert.get_subject() | ||
|
||
subject.C = b"TR" | ||
subject.ST = b"Çorum" | ||
subject.L = b"Başmakçı" | ||
subject.CN = b"localhost" | ||
subject.O = b"Mozilla Test" | ||
subject.OU = b"Autopush Test %s" % filename | ||
subject.emailAddress = b"[email protected]" | ||
subjectAltName = X509Extension(b'subjectAltName', False, b'DNS:localhost') | ||
cert.add_extensions([subjectAltName]) | ||
|
||
cert.set_serial_number(uuid.uuid4().int) | ||
cert.gmtime_adj_notBefore(0) | ||
cert.gmtime_adj_notAfter(60 * 60 * 24 * 365 * 100) | ||
|
||
cert.set_pubkey(key) | ||
|
||
if not cacert: | ||
# self sign | ||
cacert = cert | ||
cakey = key | ||
cert.set_issuer(cacert.get_subject()) | ||
cert.sign(cakey, 'sha1') | ||
|
||
with open(filename, 'wb') as fp: | ||
fp.write(dump_privatekey(FILETYPE_PEM, key)) | ||
fp.write(dump_certificate(FILETYPE_PEM, cert)) | ||
return cert, key | ||
|
||
|
||
def save_sha256(sha256): | ||
import __main__ | ||
source = getsource(__main__) | ||
source = source.splitlines(True)[:-2] | ||
with open('makecerts.py', 'wb') as fp: | ||
fp.writelines(source) | ||
fp.write("CLIENT1_SHA256 = ('%s'\n" % sha256[:SHABREAK]) | ||
fp.write(" '%s')\n" % sha256[SHABREAK:]) | ||
|
||
|
||
def main(): | ||
# self signed | ||
server, serverkey = make_cert("server.pem") | ||
client1, _ = make_cert("client1.pem", cacert=server, cakey=serverkey) | ||
make_cert("client2.pem", cacert=server, cakey=serverkey) | ||
save_sha256(client1.digest('sha256')) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() | ||
|
||
CLIENT1_SHA256 = ('2C:78:32:76:D8:2E:5F:C4:C2:3B:44:57:BA:1B:AF:1F:94:' | ||
'56:52:94:F7:5A:FE:3A:8C:7E:85:4C:6D:54:76:D2') |
Oops, something went wrong.