public void CanSetCertificates() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 462); HttpAPIManager manager = new HttpAPIManager(); manager.SetSSLInfo(testEndpoint, new SSLInfo(TestCertificate.Thumbprint)); try { var sslInfo = manager.GetSSLInfo(testEndpoint); Assert.NotNull(sslInfo); Assert.Equal(TestCertificate.Thumbprint, sslInfo.Certificate.Thumbprint); } finally { manager.RemoveSSLInfo(testEndpoint); var sslInfo = manager.GetSSLInfo(testEndpoint); Assert.Null(sslInfo); } }
public void CanSetSSLInfoTwiceAndSetToNullToRemove() { var testEndpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 464); var info = new SSLInfo(TestCertificate.Thumbprint); HttpAPIManager manager = new HttpAPIManager(); manager.SetSSLInfo(testEndpoint, info); try { Assert.NotNull(manager.GetSSLInfo(testEndpoint)); Assert.Equal(false, manager.GetSSLInfo(testEndpoint).NegotiateClientCert); info.NegotiateClientCert = true; manager.SetSSLInfo(testEndpoint, info); Assert.NotNull(manager.GetSSLInfo(testEndpoint)); Assert.Equal(true, manager.GetSSLInfo(testEndpoint).NegotiateClientCert); } finally { manager.SetSSLInfo(testEndpoint, null); Assert.Null(manager.GetSSLInfo(testEndpoint)); } }