Пример #1
0
 /// <summary>Returns a configured SSLSocketFactory.</summary>
 /// <returns>the configured SSLSocketFactory.</returns>
 /// <exception cref="GeneralSecurityException">
 /// thrown if the SSLSocketFactory could not
 /// be initialized.
 /// </exception>
 /// <exception cref="System.IO.IOException">
 /// thrown if and IO error occurred while loading
 /// the server keystore.
 /// </exception>
 public virtual SSLSocketFactory CreateSSLSocketFactory()
 {
     if (mode != SSLFactory.Mode.Client)
     {
         throw new InvalidOperationException("Factory is in CLIENT mode");
     }
     return(context.GetSocketFactory());
 }
Пример #2
0
 /// <exception cref="System.IO.IOException"></exception>
 private void DisableSslVerify(URLConnection conn)
 {
     TrustManager[] trustAllCerts = new TrustManager[] { new TransportHttp.DummyX509TrustManager
                                                             () };
     try
     {
         SSLContext ctx = SSLContext.GetInstance("SSL");
         ctx.Init(null, trustAllCerts, null);
         HttpsURLConnection sslConn = (HttpsURLConnection)conn;
         sslConn.SetSSLSocketFactory(ctx.GetSocketFactory());
     }
     catch (KeyManagementException e)
     {
         throw new IOException(e.Message);
     }
     catch (NoSuchAlgorithmException e)
     {
         throw new IOException(e.Message);
     }
 }