From e01be7ed365d568c50167ec2e00fa1339ee918dc Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Thu, 19 Sep 2019 11:22:15 -0700 Subject: [PATCH] ClientTlsContext tests and rename-o-rama (#68) The arguments to these functions confused me so I renamed them. --- awscrt/io.py | 55 +++++++++++++++++------------------ source/io.c | 17 ++++++----- test/files/short.txt | 24 --------------- test/resources/unittests.crt | 23 +++++++++++++++ test/resources/unittests.csr | 18 ++++++++++++ test/resources/unittests.key | 27 +++++++++++++++++ test/resources/unittests.p12 | Bin 0 -> 2581 bytes test/test_io.py | 28 +++++++++++++++++- 8 files changed, 131 insertions(+), 61 deletions(-) delete mode 100644 test/files/short.txt create mode 100755 test/resources/unittests.crt create mode 100755 test/resources/unittests.csr create mode 100755 test/resources/unittests.key create mode 100644 test/resources/unittests.p12 diff --git a/awscrt/io.py b/awscrt/io.py index 71764d1a6..f27d8795d 100644 --- a/awscrt/io.py +++ b/awscrt/io.py @@ -129,9 +129,9 @@ class TlsVersion(IntEnum): class TlsContextOptions(object): __slots__ = ( - 'min_tls_ver', 'ca_path', 'ca_buffer', 'alpn_list', + 'min_tls_ver', 'ca_dirpath', 'ca_buffer', 'alpn_list', 'certificate_buffer', 'private_key_buffer', - 'pkcs12_path', 'pkcs12_password', 'verify_peer') + 'pkcs12_filepath', 'pkcs12_password', 'verify_peer') def __init__(self): @@ -141,17 +141,16 @@ def __init__(self): self.min_tls_ver = TlsVersion.DEFAULT self.verify_peer = True - def override_default_trust_store_from_path(self, ca_path, ca_file): + def override_default_trust_store_from_path(self, ca_dirpath, ca_filepath): - assert isinstance_str(ca_path) or ca_path is None - assert isinstance_str(ca_file) or ca_file is None + assert isinstance_str(ca_dirpath) or ca_dirpath is None + assert isinstance_str(ca_filepath) or ca_filepath is None - ca_buffer = None - if ca_file: - ca_buffer = _read_binary_file(ca_file) + if ca_filepath: + ca_buffer = _read_binary_file(ca_filepath) + self.override_default_trust_store(ca_buffer) - self.ca_path = ca_path - self.override_default_trust_store(ca_buffer) + self.ca_dirpath = ca_dirpath def override_default_trust_store(self, rootca_buffer): assert isinstance(rootca_buffer, bytes) @@ -159,13 +158,13 @@ def override_default_trust_store(self, rootca_buffer): self.ca_buffer = rootca_buffer @staticmethod - def create_client_with_mtls_from_path(cert_path, pk_path): + def create_client_with_mtls_from_path(cert_filepath, pk_filepath): - assert isinstance_str(cert_path) - assert isinstance_str(pk_path) + assert isinstance_str(cert_filepath) + assert isinstance_str(pk_filepath) - cert_buffer = _read_binary_file(cert_path) - key_buffer = _read_binary_file(pk_path) + cert_buffer = _read_binary_file(cert_filepath) + key_buffer = _read_binary_file(pk_filepath) return TlsContextOptions.create_client_with_mtls(cert_buffer, key_buffer) @@ -182,25 +181,25 @@ def create_client_with_mtls(cert_buffer, key_buffer): return opt @staticmethod - def create_client_with_mtls_pkcs12(pkcs12_path, pkcs12_password): + def create_client_with_mtls_pkcs12(pkcs12_filepath, pkcs12_password): - assert isinstance_str(pkcs12_path) + assert isinstance_str(pkcs12_filepath) assert isinstance_str(pkcs12_password) opt = TlsContextOptions() - opt.pkcs12_path = pkcs12_path + opt.pkcs12_filepath = pkcs12_filepath opt.pkcs12_password = pkcs12_password opt.verify_peer = True return opt @staticmethod - def create_server_from_path(cert_path, pk_path): + def create_server_from_path(cert_filepath, pk_filepath): - assert isinstance_str(cert_path) - assert isinstance_str(pk_path) + assert isinstance_str(cert_filepath) + assert isinstance_str(pk_filepath) - cert_buffer = _read_binary_file(cert_path) - key_buffer = _read_binary_file(pk_path) + cert_buffer = _read_binary_file(cert_filepath) + key_buffer = _read_binary_file(pk_filepath) return TlsContextOptions.create_server(cert_buffer, key_buffer) @@ -216,13 +215,13 @@ def create_server(cert_buffer, key_buffer): return opt @staticmethod - def create_server_pkcs12(pkcs12_path, pkcs12_password): + def create_server_pkcs12(pkcs12_filepath, pkcs12_password): - assert isinstance_str(pkcs12_path) + assert isinstance_str(pkcs12_filepath) assert isinstance_str(pkcs12_password) opt = TlsContextOptions() - opt.pkcs12_path = pkcs12_path + opt.pkcs12_filepath = pkcs12_filepath opt.pkcs12_password = pkcs12_password opt.verify_peer = False return opt @@ -237,12 +236,12 @@ def __init__(self, options): super(ClientTlsContext, self).__init__() self._binding = _awscrt.client_tls_ctx_new( options.min_tls_ver.value, - options.ca_path, + options.ca_dirpath, options.ca_buffer, options.alpn_list, options.certificate_buffer, options.private_key_buffer, - options.pkcs12_path, + options.pkcs12_filepath, options.pkcs12_password, options.verify_peer ) diff --git a/source/io.c b/source/io.c index 8744ce7f9..bb5566fee 100644 --- a/source/io.c +++ b/source/io.c @@ -369,7 +369,7 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) { struct aws_allocator *allocator = aws_py_get_allocator(); int min_tls_version; - const char *ca_path; + const char *ca_dirpath; const char *ca_buffer; Py_ssize_t ca_buffer_len; const char *alpn_list; @@ -377,14 +377,14 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) { Py_ssize_t certificate_buffer_len; const char *private_key_buffer; Py_ssize_t private_key_buffer_len; - const char *pkcs12_path; + const char *pkcs12_filepath; const char *pkcs12_password; uint8_t verify_peer; if (!PyArg_ParseTuple( args, "bzz#zz#z#zzb", &min_tls_version, - &ca_path, + &ca_dirpath, &ca_buffer, &ca_buffer_len, &alpn_list, @@ -392,7 +392,7 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) { &certificate_buffer_len, &private_key_buffer, &private_key_buffer_len, - &pkcs12_path, + &pkcs12_filepath, &pkcs12_password, &verify_peer)) { return NULL; @@ -415,8 +415,8 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) { ctx_options.minimum_tls_version = min_tls_version; - if (ca_path) { - if (aws_tls_ctx_options_override_default_trust_store_from_path(&ctx_options, ca_path, NULL)) { + if (ca_dirpath) { + if (aws_tls_ctx_options_override_default_trust_store_from_path(&ctx_options, ca_dirpath, NULL)) { PyErr_SetAwsLastError(); goto ctx_options_failure; } @@ -438,9 +438,10 @@ PyObject *aws_py_client_tls_ctx_new(PyObject *self, PyObject *args) { } #ifdef __APPLE__ - if (pkcs12_path && pkcs12_password) { + if (pkcs12_filepath && pkcs12_password) { struct aws_byte_cursor password = aws_byte_cursor_from_c_str(pkcs12_password); - if (aws_tls_ctx_options_init_client_mtls_pkcs12_from_path(&ctx_options, allocator, pkcs12_path, &password)) { + if (aws_tls_ctx_options_init_client_mtls_pkcs12_from_path( + &ctx_options, allocator, pkcs12_filepath, &password)) { PyErr_SetAwsLastError(); goto ctx_options_failure; } diff --git a/test/files/short.txt b/test/files/short.txt deleted file mode 100644 index c9be95214..000000000 --- a/test/files/short.txt +++ /dev/null @@ -1,24 +0,0 @@ -z1eJS6O4qkUllKqTW9dQUEjH0s5JhU6TtbP0hz14rRl1Y1EHc62a_g -iqryRvz6tvPMP692DBpBRVlUgLh8H9R5Oqe5TQVEJzfcgxa02U1SKQ -87ns4D2qWE9rdh7MSAqt0-CheJIwwPF4saP-9FbmhmbFU8IfdH8R1g -2tBj0cC9uq9Sy5gcCqfnjBzr4tv6dWlPwPPkaSd7I7K71c9kablSLQ -YII-b3mOb6Vme1zdF0MeZqdb96YTZoiPJDmb30bGPGAM-1iXKdT9mg -csoCRXOhQ8LeLG8rkvXButT64AoFbCw92JTRqR5d_4OoSQNJZpSvUg -YrdhPY6lAHAIImpdtRU14Yr2diloXzYRrACcOxfGJurf8Tr6UuwWjA -i2MAVS0Ps0d9qwCPt8d1ViCNAopEdCFcrDn236v7z2uAP-SwV4S0HQ -SYDPYrwOqwq8rtycXog3Mnp2ui8Ff5YwM6Foy39C2eZ7-HG4_BEJeA -zugR1hFDZwGNEVmZwD8XSaayvG7w21UcGiaK652IpzQ-v30wOvWc5w -dLKjAijHLlLwtYm_o5gux4F2oX2qC4TprpuBekHfl02-pEzsQ5Fllw -G1hdD4jXF1bLKyeIGs3jp3U_3yx32a3jiu3cA3r4-9rg_sfDwxh1PQ -kkJpucBK18ue9djRkXgBBQgEmZXTMibnunYdt_xXn4cAhC-p3W9BNA --2PKi8aJi8BzT1Gy8QIzpwqclO_UIETGMO9cZMlQN1JScCVmHlOrNQ -oFQpvHlxaN1RRUzYeQFSSqF4jW9i3riJfxj8IJzMSGNMhlSVBlz4Xw -Ivq3tIdA3Vm7-_InU1m1GNlTW484y-c5u-7A9mJdURIcjHoAwdNxDQ -jeKzehi3JLJh15y3uHfA2ZWVx86ntCLzv21O-JPPAwsIOqM-iJWpwQ -8CXLOVuF3ZrZVttxUGis4gkk0tp3s_uAu55-LAmA-WjJEUvK8-D2pQ -TLpARAZjC97tQ7Z2PcTB2U8SQnTgVVyHr5oBzCbvDsxi9UJyTL1Odg -DP7uHGz0GV0ZAOqoQP-c7jhA6xRIUqlOt1rv9NyM21cn3KF0xlwK_A -yZcAds37ivvrAWI0KzTvJAwk1mH74ntplSarLQo_gX0Mflf3ypjDlg -8p85B-nd6o2WwYCd6kVKJ5AF5I_XVIgy_koxCVAC16rsfmxd9e5WvQ -zjnkg61HSepRUENwjghI9LN4BnvZMYYmhTZ-5OKDQLUjFC3S3j-emA -O-wY3IQplATbuhFQOCMCq7qxxURE_iRxuwdATAOA2g-WODSeN52v2A \ No newline at end of file diff --git a/test/resources/unittests.crt b/test/resources/unittests.crt new file mode 100755 index 000000000..d3de8639f --- /dev/null +++ b/test/resources/unittests.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIIDzjCCArYCCQCoztOER4pOkzANBgkqhkiG9w0BAQsFADCBqDELMAkGA1UEBhMC +VVMxEzARBgNVBAgMCldhc2hpbmd0b24xEDAOBgNVBAcMB1NlYXR0bGUxIDAeBgNV +BAoMF0FtYXpvbiBXZWIgU2VydmljZXMgSW5jMRswGQYDVQQLDBJBV1MgU0RLcyBh +bmQgVG9vbHMxEjAQBgNVBAMMCWxvY2FsaG9zdDEfMB0GCSqGSIb3DQEJARYQaGVu +c29AYW1hem9uLmNvbTAeFw0xNzA5MDEwMjE2MThaFw00NTAxMTcwMjE2MThaMIGo +MQswCQYDVQQGEwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjEQMA4GA1UEBwwHU2Vh +dHRsZTEgMB4GA1UECgwXQW1hem9uIFdlYiBTZXJ2aWNlcyBJbmMxGzAZBgNVBAsM +EkFXUyBTREtzIGFuZCBUb29sczESMBAGA1UEAwwJbG9jYWxob3N0MR8wHQYJKoZI +hvcNAQkBFhBoZW5zb0BhbWF6b24uY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A +MIIBCgKCAQEA12pXSPgORAMlQtYRbxuz/Ocaoran3C2Fjyjhu0vucSEZSwxDJp75 +TBQEMafSpSEKAQLeDt7xuDRDYn52V4UE6cF+xTWhtzsf7mhN/lHaDPcvR2ASPAEk +zkil8KCLY4e6tTxSwQ97splNuEZ099HoJYTTLFaReIfd1D3zZ1EYcSw8w+GZ2SxE +UfYUSL2CFmIYSkQjnlsJCIpCoGgDiBAPbIUJO3KWBDX0JgGDbx3Wf3jXG/Y6T63L +PsO+AS20RCvcEF0F/rlDINzI5EAHO1TOEd9fKOu+JAK06Pw1m77BgOrE7FtvIG7k +YNVuOEPeInOHkOuqryDisB1PwiyPNIbqdQIDAQABMA0GCSqGSIb3DQEBCwUAA4IB +AQDL3vA0QeYb+XE8pUm3lxwso4zf0lwYi8Fni23ThqlvTNrP0glaWNu28aa03F5r +Jc80acRjySG8q/gqwMMLOE+xqLgTzAHLYDnX2BZdaeIJWdgQP/YrWACrnYlVJ4kZ +fi3QiBU0b5OgQdwX0csr6NQ7fv5i9EiNdPf+Ll1gxQj0Q0AaJzb4+TUL4dHZV3L6 +RRRK5KpTI3I+5A3vLSYSgwlVT+qB4J6+Z7O9SZX8s0xnm569tECbRnDDYv3E90SU +QMN6Rzsr2crUzQSMq2hQTnrpFvRX52Yw7Dkz4SgkP3Q4xzvITPgA8REgHd4eDgrz +36J362qmeHxjl/+KLxv/Vr4b +-----END CERTIFICATE----- diff --git a/test/resources/unittests.csr b/test/resources/unittests.csr new file mode 100755 index 000000000..6d2a62964 --- /dev/null +++ b/test/resources/unittests.csr @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIC7jCCAdYCAQAwgagxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApXYXNoaW5ndG9u +MRAwDgYDVQQHDAdTZWF0dGxlMSAwHgYDVQQKDBdBbWF6b24gV2ViIFNlcnZpY2Vz +IEluYzEbMBkGA1UECwwSQVdTIFNES3MgYW5kIFRvb2xzMRIwEAYDVQQDDAlsb2Nh +bGhvc3QxHzAdBgkqhkiG9w0BCQEWEGhlbnNvQGFtYXpvbi5jb20wggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDXaldI+A5EAyVC1hFvG7P85xqitqfcLYWP +KOG7S+5xIRlLDEMmnvlMFAQxp9KlIQoBAt4O3vG4NENifnZXhQTpwX7FNaG3Ox/u +aE3+UdoM9y9HYBI8ASTOSKXwoItjh7q1PFLBD3uymU24RnT30eglhNMsVpF4h93U +PfNnURhxLDzD4ZnZLERR9hRIvYIWYhhKRCOeWwkIikKgaAOIEA9shQk7cpYENfQm +AYNvHdZ/eNcb9jpPrcs+w74BLbREK9wQXQX+uUMg3MjkQAc7VM4R318o674kArTo +/DWbvsGA6sTsW28gbuRg1W44Q94ic4eQ66qvIOKwHU/CLI80hup1AgMBAAGgADAN +BgkqhkiG9w0BAQsFAAOCAQEASvXJuyYUTu58xtT2kAE9J8OQdyfYvAiTskN7JNHq +Y3Dcj1IsHfpsthbop5sgoXFYnPDBHQjd5c8KD8SgzSwjReeGQFUUsdG8uB6w2dhM +Kbqiz/Ny0AD+HyuVN3PqavbGJqcIetabskAxX5TP943WYveaJcz8D7+6B97S2Vk5 +5o8oiOeNOPqn2UC8erHjkw1kf1Rl4wa2jbmcrUjvsM9DiekYdbpAr+3xgoRDj03J +bvTv4p2RQyO8hHaRX0zlpidXyfOEAjMz6ZqhItE++pxSbZ0aNfzm/c12CsTqB4ZA +nGgVk67n/vmEPtobZGhIZoDGBsh1HJyApNX+JEP/av56gg== +-----END CERTIFICATE REQUEST----- diff --git a/test/resources/unittests.key b/test/resources/unittests.key new file mode 100755 index 000000000..a4cea74fb --- /dev/null +++ b/test/resources/unittests.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA12pXSPgORAMlQtYRbxuz/Ocaoran3C2Fjyjhu0vucSEZSwxD +Jp75TBQEMafSpSEKAQLeDt7xuDRDYn52V4UE6cF+xTWhtzsf7mhN/lHaDPcvR2AS +PAEkzkil8KCLY4e6tTxSwQ97splNuEZ099HoJYTTLFaReIfd1D3zZ1EYcSw8w+GZ +2SxEUfYUSL2CFmIYSkQjnlsJCIpCoGgDiBAPbIUJO3KWBDX0JgGDbx3Wf3jXG/Y6 +T63LPsO+AS20RCvcEF0F/rlDINzI5EAHO1TOEd9fKOu+JAK06Pw1m77BgOrE7Ftv +IG7kYNVuOEPeInOHkOuqryDisB1PwiyPNIbqdQIDAQABAoIBAESQuI+lRQUo6ydG +8+2lp7iL5tJ7yRov8x8KKC9xj8e6fU6B7K3SVA9/H4aeoFGnHoQL4ZpiJBY5rGkh +T5Gz6UhuKmejFoI384Xy9UBJ1VnjI81YKvWmd4yhWxAoSbW4chlVxhFlWD4UxcQt +yPVIftfSW1T1iQAQXu87eMod6eW7VWlyMKicYkBGB2ohI0hW8chx361z96QcpxhA +yBAfnhxuTgKFYSRVfwYSOjHYPOvozmU7Wj0iURT+1MM4iO8YlBDuZEJArs3WAdIe +pmCq6snzOAJ6Y9iE0EGti9QGiAo6na/nWAfVlRSMyS/C1GC0oM0MnpRKSLW0tvLV +vtJG81ECgYEA7lzGpdlAKwWNKPc2YIbtUNomD/eOr7TzYedYxJ88SG52THjgE3Pu +poF3wZFjdtlwx1u4nsxlVe50FBTCN5s2FV4/8YP980zis+HtUC5pWCO3Oy6+DjSj +K9st+mGyzYjl3opVqcQZkHj1LPqNxBmvFpDgAtVZfdKSdyuzZpj8s5sCgYEA51rj +EFa/ijILp1P5vKn8b3pIfQFSsUsX5NXTy31f/2UwVV491djMyNyhtaRcrXP9CYpq +38o1xvUaxe2hlND/jiBjBHfsC13oUOVz8TrAzxDKAzbGLcOT2trgxMFbR8Ez+jur +1yQbPnoKZrB7SopAkcVqZv4ks0LLu+BLfEFXYy8CgYEApN8xXDgoRVnCqQpN53iM +n/c0iqjOXkTIb/jIksAdv3AAjaayP2JaOXul7RL2fJeshYiw684vbb/RNK6jJDlM +sH0Pt6t3tZmB2bC1KFfh7+BMdjg/p63LC6PAasa3GanObh67YADPOfoghCsOcgzd +6brt56fRDdHgE2P75ER/zm8CgYEArAxx6bepT3syIWiYww3itYBJofS26zP9++Zs +T9rX5hT5IbMo5vwIJqO0+mDVrwQfu9Wc7vnwjhm+pEy4qfPW6Hn7SNppxnY6itZo +J4/azOIeaM92B5h3Pv0gxBFK8YyjO8beXurx+79ENuOtfFxd8knOe/Mplcnpurjt +SeVJuG8CgYBxEYouOM9UuZlblXQXfudTWWf+x5CEWxyJgKaktHEh3iees1gB7ZPb +OewLa8AYVjqbNgS/r/aUFjpBbCov8ICxcy86SuGda10LDFX83sbyMm8XhktfyC3L +54irVW5mNUDcA8s9+DloeTlUlJIr8J/RADC9rpqHLaZzcdvpIMhVsw== +-----END RSA PRIVATE KEY----- diff --git a/test/resources/unittests.p12 b/test/resources/unittests.p12 new file mode 100644 index 0000000000000000000000000000000000000000..83c6c0ab7ae1f6380176887e7ef55e259a04e5a1 GIT binary patch literal 2581 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 literal 0 HcmV?d00001 diff --git a/test/test_io.py b/test/test_io.py index 20a4cc284..7c8b1ddcb 100644 --- a/test/test_io.py +++ b/test/test_io.py @@ -12,7 +12,7 @@ # permissions and limitations under the License. from __future__ import absolute_import -from awscrt.io import ClientBootstrap, DefaultHostResolver, EventLoopGroup +from awscrt.io import ClientBootstrap, ClientTlsContext, DefaultHostResolver, EventLoopGroup, TlsContextOptions from test import NativeResourceTest import unittest @@ -42,5 +42,31 @@ def test_init(self): bootstrap = ClientBootstrap(event_loop_group, host_resolver) +class ClientTlsContextTest(NativeResourceTest): + def test_init_defaults(self): + opt = TlsContextOptions() + ctx = ClientTlsContext(opt) + + def test_with_mtls_from_path(self): + opt = TlsContextOptions.create_client_with_mtls_from_path( + 'test/resources/unittests.crt', 'test/resources/unittests.key') + ctx = ClientTlsContext(opt) + + def test_with_mtls_pkcs12(self): + opt = TlsContextOptions.create_client_with_mtls_pkcs12( + 'test/resources/unittests.p12', '1234') + ctx = ClientTlsContext(opt) + + def test_override_default_trust_store_dir(self): + opt = TlsContextOptions() + opt.override_default_trust_store_from_path('test/resources', None) + ctx = ClientTlsContext(opt) + + def test_override_default_trust_store_file(self): + opt = TlsContextOptions() + opt.override_default_trust_store_from_path(None, 'test/resources/unittests.crt') + ctx = ClientTlsContext(opt) + + if __name__ == '__main__': unittest.main()