Пример #1
0
 def test_simple_ssl(self):
     """ Server uses its cert, client uses none.
     """
     server_port = 9001
     with TestSSL._ClientServerContextManager(server_port):
         client = SSLClient("https://localhost:%d/RPC2" % server_port, ca_certs)
         self.assertEqual(client.test_server(), RESULT_OK)
Пример #2
0
 def test_simple_ssl(self):
     """ Server uses its cert, client uses none.
     """
     server_port = 9001
     with TestSSL._ClientServerContextManager(server_port):
         client = SSLClient("https://localhost:%d/RPC2" % server_port,
                            ca_certs)
         self.assertEqual(client.test_server(), RESULT_OK)
Пример #3
0
 def test_client_cert(self):
     """ Server & client use certs.
     """
     server_port = 9002
     with TestSSL._ClientServerContextManager(server_port, ssl.CERT_REQUIRED):
         client = SSLClient("https://localhost:%d/RPC2" % server_port, ca_certs,
                            client_key, client_cert)
         self.assertEqual(client.test_server(), RESULT_OK)
Пример #4
0
 def test_client_cert(self):
     """ Server & client use certs.
     """
     server_port = 9002
     with TestSSL._ClientServerContextManager(server_port,
                                              ssl.CERT_REQUIRED):
         client = SSLClient("https://localhost:%d/RPC2" % server_port,
                            ca_certs, client_key, client_cert)
         self.assertEqual(client.test_server(), RESULT_OK)
Пример #5
0
    def test_client_cert_verify_ok(self):
        """ Server & client use certs. Server succesfully validates client certificate's fields.
        """
        server_port = 9003
        verify_fields = {"commonName":"My Client", "countryName":"US",
                         "organizationalUnitName":"My Unit", "organizationName":"My Company",
                         "stateOrProvinceName":"My State"}

        with TestSSL._ClientServerContextManager(server_port, ssl.CERT_REQUIRED, verify_fields):
            client = SSLClient("https://localhost:%d/RPC2" % server_port, ca_certs,
                               client_key, client_cert)
            self.assertEqual(client.test_server(), RESULT_OK)
Пример #6
0
    def test_client_cert_verify_ok(self):
        """ Server & client use certs. Server succesfully validates client certificate's fields.
        """
        server_port = 9003
        verify_fields = {
            "commonName": "My Client",
            "countryName": "US",
            "organizationalUnitName": "My Unit",
            "organizationName": "My Company",
            "stateOrProvinceName": "My State"
        }

        with TestSSL._ClientServerContextManager(server_port,
                                                 ssl.CERT_REQUIRED,
                                                 verify_fields):
            client = SSLClient("https://localhost:%d/RPC2" % server_port,
                               ca_certs, client_key, client_cert)
            self.assertEqual(client.test_server(), RESULT_OK)