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
17 changed files
with
580 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
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----- | ||
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD04uku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EvZTVaGKdTaxQoxQPzr1 | ||
-----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 @@ | ||
6C:DC:75:4D:0E:D1:25:B8:F4:46:E0:FC:66:2E:03:49:EB:37:33:82:19:94:2B:CE:CF:4F:E3:E8:AA:5E:81:1A |
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,53 @@ | ||
-----BEGIN PRIVATE KEY----- | ||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDQ25kt31KETmsU | ||
ux1rc974Yo0OpWsj1Es6TMZ94TmNSk+eZvctB+wS4a2wh2QHuR6XYyuRgTvIapIf | ||
zb/qyNzfcZ+TuJKnsXxu7gBXWqSMxpaZd1pc0cRllwh2GlwIC0ARl8d3O//iP+36 | ||
uIqhM1iTrd9833WDSV6it+8xDgBGgb3B+ZeenLqXJUqqhBeWh2ERZHhe3APad5UA | ||
1vF9nSQTiRtAK8dMS+HvBugC37Yhvcgp+sFu64iDTjYi+DkOjZNVeLw9WH2XxMqR | ||
sx34VkAZw4F8xkay5sgjydzaoP+7HxNvclQDMaq/u7pUpP9lsZmPvbsfqKGv2D5l | ||
bkCbzWWVAgMBAAECggEBAKyrwPph1XC4/GKJSAtcIo0rvP7M18UpcIBklP3hRJmB | ||
RE3rRpMeJ5h8qAJ4DMUt0RLL1GtZcrmBEgnlKrPLGIBLCekxAV5OqFd1wSZ3M++H | ||
B18dg8GVU0/CDCbIKComUvO4jhoPqr+8pt1P0JzxPFvrtgchH6BI+kqA0um1b5jZ | ||
jwkVyUc/IdCR8jz0pYrdWn5MSq3ZK+Lr7XG2ODJimmEz0dNfnJa3i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7pUpP9lsZmPvbsfqKGv2D5lbkCbzWWVAgMBAAGjGDAWMBQGA1UdEQQN | ||
MAuCCWxvY2FsaG9zdDANBgkqhkiG9w0BAQUFAAOCAQEAWHoQ2+ChM9QylCLoOrLA | ||
r2r4NT/C1RErRt+h4hfIJXPc+zrBs232N7gWqUfpwnsqGu4f+98ro5o63l7m/Fi3 | ||
dAUW8WjDzeMyQ8ygWHQFD9MZYyUHrvwPiw0DNyMiZ329SWsvAOB/wNCr2fRrd2KO | ||
zdGnV0yHZD9GdffDwvxyKVAoKRFtiIZjBqgoWmSDPeN3evYDNcQvJXPadcId8426 | ||
aOZJtEsGZG9CtocrwyV0VufWt41mvUcS6LzPJYeKWbOslguv7CQ10gIFSogS79s9 | ||
nE+TleQFff3H0Qt2CBlAA9txLwma8ha9SS9xL/UGWZlbzwJlbdEbJATgaHvrD9Vn | ||
Vw== | ||
-----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,63 @@ | ||
# encoding: utf-8 | ||
|
||
import os | ||
import uuid | ||
|
||
from OpenSSL.crypto import ( | ||
FILETYPE_PEM, PKey, TYPE_RSA, X509, X509Extension, | ||
dump_certificate, dump_privatekey) | ||
|
||
|
||
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 main(): | ||
certsdir = os.path.dirname(__file__) | ||
|
||
# server.pem is self signed | ||
server, serverkey = make_cert(os.path.join(certsdir, "server.pem")) | ||
|
||
client1, _ = make_cert(os.path.join(certsdir, "client1.pem"), | ||
cacert=server, cakey=serverkey) | ||
make_cert(os.path.join(certsdir, "client2.pem"), | ||
cacert=server, cakey=serverkey) | ||
|
||
with open(os.path.join(certsdir, "client1_sha256.txt"), 'w') as fp: | ||
fp.write(client1.digest('sha256')) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.