Пример #1
0
        public void TestCase()
        {
            string serverCertPath           = @"/certs/server.pfx";
            string serverPrivateKeyPassword = "******";
            string caFilePath               = "/certs/ca_chain.pem";
            string clientCertPath           = "/certs/client.pfx";
            string clientPrivateKeyPassword = "******";
            string projDir = Directory.GetParent(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).FullName).FullName;

            // Initialize OpenSSL for multithreaded use
            ThreadInitialization.InitializeThreads();
            try {
                // Intitialize server certificates
                serverCAChain     = LoadCACertificateChain(projDir + caFilePath);
                serverCertificate = LoadPKCS12Certificate(projDir + serverCertPath, serverPrivateKeyPassword);

                // Kick the server thread
                Thread serverThread = new Thread(new ThreadStart(ServerTestThreadProc));
                serverThread.Start();

                // Intialize the client certificates
                clientCAChain = LoadCACertificateChain(projDir + caFilePath);
                X509Certificate clientCert = LoadPKCS12Certificate(projDir + clientCertPath, clientPrivateKeyPassword);
                // Add the cert to the client certificate list
                clientCertificateList = new X509List();
                clientCertificateList.Add(clientCert);

                // Kick the client thread
                Thread clientThread = new Thread(new ThreadStart(ClientTestThreadProc));
                clientThread.Start();

                // Wait for the threads to exit
                serverThread.Join();
                clientThread.Join();

                // Cleanup
                serverCertificate.Dispose();
                serverCAChain.Dispose();
                clientCAChain.Dispose();
                clientCert.Dispose();
            }
            catch (Exception ex) {
                Console.WriteLine("Server test failed with exception: {0}", ex.Message);
            }
            ThreadInitialization.UninitializeThreads();
        }
Пример #2
0
        public void Execute(string[] args)
        {
            string serverCertPath           = @"../../test/certs/server.pfx";
            string serverPrivateKeyPassword = "******";
            string caFilePath               = "../../test/certs/ca_chain.pem";
            string clientCertPath           = "../../test/certs/client.pfx";
            string clientPrivateKeyPassword = "******";

            // Initialize OpenSSL for multithreaded use
            ThreadInitialization.InitializeThreads();
            try {
                // Intitialize server certificates
                serverCAChain     = LoadCACertificateChain(caFilePath);
                serverCertificate = LoadPKCS12Certificate(serverCertPath, serverPrivateKeyPassword);

                // Kick the server thread
                Thread serverThread = new Thread(new ThreadStart(ServerTestThreadProc));
                serverThread.Start();

                // Intialize the client certificates
                clientCAChain = LoadCACertificateChain(caFilePath);
                X509Certificate clientCert = LoadPKCS12Certificate(clientCertPath, clientPrivateKeyPassword);
                // Add the cert to the client certificate list
                clientCertificateList = new X509List();
                clientCertificateList.Add(clientCert);

                // Kick the client thread
                Thread clientThread = new Thread(new ThreadStart(ClientTestThreadProc));
                clientThread.Start();

                // Wait for the threads to exit
                serverThread.Join();
                clientThread.Join();

                // Cleanup
                serverCertificate.Dispose();
                serverCAChain.Dispose();
                clientCAChain.Dispose();
                clientCert.Dispose();
            }
            catch (Exception ex) {
                Console.WriteLine("Server test failed with exception: {0}", ex.Message);
            }
            ThreadInitialization.UninitializeThreads();
        }
Пример #3
0
		public void TestCase() {
			string serverCertPath = @"../../test/certs/server.pfx";
			string serverPrivateKeyPassword = "******";
			string caFilePath = "../../test/certs/ca_chain.pem";
			string clientCertPath = "../../test/certs/client.pfx";
			string clientPrivateKeyPassword = "******";

			// Initialize OpenSSL for multithreaded use
			ThreadInitialization.InitializeThreads();
			try {
				// Intitialize server certificates
				serverCAChain = LoadCACertificateChain(caFilePath);
				serverCertificate = LoadPKCS12Certificate(serverCertPath, serverPrivateKeyPassword);

				// Kick the server thread
				Thread serverThread = new Thread(new ThreadStart(ServerTestThreadProc));
				serverThread.Start();

				// Intialize the client certificates
				clientCAChain = LoadCACertificateChain(caFilePath);
				X509Certificate clientCert = LoadPKCS12Certificate(clientCertPath, clientPrivateKeyPassword);
				// Add the cert to the client certificate list
				clientCertificateList = new X509List();
				clientCertificateList.Add(clientCert);

				// Kick the client thread
				Thread clientThread = new Thread(new ThreadStart(ClientTestThreadProc));
				clientThread.Start();

				// Wait for the threads to exit
				serverThread.Join();
				clientThread.Join();

				// Cleanup
				serverCertificate.Dispose();
				serverCAChain.Dispose();
				clientCAChain.Dispose();
				clientCert.Dispose();
			}
			catch (Exception ex) {
				Console.WriteLine("Server test failed with exception: {0}", ex.Message);
			}
			ThreadInitialization.UninitializeThreads();
		}