Exemplo n.º 1
0
        public void CanAttachCTLToSSLInfo()
        {
            var testEndpoint          = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 2924);
            CTLContextBuilder builder = new CTLContextBuilder();

            builder.CTLInfo.ListIdentifier = "my test list binding";
            builder.CTLInfo.Certificates.Add(Verisign);
            builder.CTLInfo.Certificates.Add(KisaRoot1);
            builder.Signers.Add(TestCertificate);
            HttpAPIManager manager = new HttpAPIManager();
            var            context = builder.ToCTLContext();

            try
            {
                context.ImportInStore(StoreLocation.LocalMachine, StoreName.Root);
                SSLInfo info = new SSLInfo();
                info.CheckClientCertificate = false;
                info.NegotiateClientCert    = true;
                info.CTLIdentifier          = context.CTLInfo.ListIdentifier;
                info.CTLStoreName           = StoreName.Root;
                info.Certificate            = TestCertificate;
                manager.SetSSLInfo(testEndpoint, info);
            }
            finally
            {
                context.RemoveFromStore(StoreLocation.LocalMachine, StoreName.Root);
                manager.RemoveSSLInfo(testEndpoint);
            }
        }
Exemplo n.º 2
0
 public SSLInfo GetSSLInfo(IPEndPoint endpoint)
 {
     using (new HttpInitializeScope())
     {
         return(SSLInfo.Get(endpoint));
     }
 }
Exemplo n.º 3
0
 public void RemoveSSLInfo(IPEndPoint endpoint)
 {
     using (new HttpInitializeScope())
     {
         var info = new SSLInfo();
         info.Endpoint = endpoint;
         info.Delete();
     }
 }
Exemplo n.º 4
0
 public void HasMeaningfulErrorMessageIfHttpApiNotInitialized()
 {
     try
     {
         SSLInfo.Get(0);
     }
     catch (InvalidOperationException ex)
     {
         Assert.Equal("You should first initialize HTTP Server API with HttpInitializeScope", ex.Message);
     }
 }
Exemplo n.º 5
0
 public override void Execute(object parameter)
 {
     if (CanExecute(null))
     {
         var info = new SSLInfo();
         info.SetCertificate(StoreName.My, ViewModel.SelectedCertificate.Thumbprint);
         new HttpAPIManager().SetSSLInfo(ViewModel.CreateSSLIPEndpoint(), info);
         ViewModel.SSLInfos.Add(new SSLInfoViewModel(info, ViewModel));
         ViewModel.SSLPort             = 443;
         ViewModel.SSLIp               = "";
         ViewModel.SelectedCertificate = null;
     }
 }
Exemplo n.º 6
0
 public void SetSSLInfo(IPEndPoint endpoint, SSLInfo info)
 {
     using (new HttpInitializeScope())
     {
         if (info == null)
         {
             RemoveSSLInfo(endpoint);
         }
         else
         {
             info.Endpoint = endpoint;
             info.Update();
         }
     }
 }
Exemplo n.º 7
0
 public IEnumerable <SSLInfo> GetSSLInfos()
 {
     using (new HttpInitializeScope())
     {
         SSLInfo sslInfo;
         int     i = 0;
         do
         {
             sslInfo = SSLInfo.Get(i);
             if (sslInfo != null)
             {
                 yield return(sslInfo);
             }
             i++;
         } while(sslInfo != null);
     }
 }
Exemplo n.º 8
0
        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));
            }
        }
Exemplo n.º 9
0
 public SSLInfoViewModel(SSLInfo info, MainWindowViewModel parent)
 {
     _Info   = info;
     _Parent = parent;
 }