private SslConnectionFactory CreateSslConnectionFactory(SslPolicy sslPolicy) { SslContextFactory sslContextFactory = new SslContextFactory(); string password = System.Guid.randomUUID().ToString(); sslContextFactory.KeyStore = sslPolicy.GetKeyStore(password.ToCharArray(), password.ToCharArray()); sslContextFactory.KeyStorePassword = password; sslContextFactory.KeyManagerPassword = password; IList <string> ciphers = sslPolicy.CipherSuites; if (ciphers != null) { sslContextFactory.IncludeCipherSuites = ciphers.ToArray(); sslContextFactory.setExcludeCipherSuites(); } string[] protocols = sslPolicy.TlsVersions; if (protocols != null) { sslContextFactory.IncludeProtocols = protocols; sslContextFactory.setExcludeProtocols(); } switch (sslPolicy.ClientAuth) { case REQUIRE: sslContextFactory.NeedClientAuth = true; break; case OPTIONAL: sslContextFactory.WantClientAuth = true; break; case NONE: sslContextFactory.WantClientAuth = false; sslContextFactory.NeedClientAuth = false; break; default: throw new System.ArgumentException("Not supported: " + sslPolicy.ClientAuth); } return(new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString())); }