Java Code Examples for javax.net.ssl.TrustManager
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project 4308Cirrus, under directory /tendril-android-lib/src/main/java/edu/colorado/cs/cirrus/android/ssl/.
Source file: EasySSLSocketFactory.java

public EasySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 2
From project friendica-for-android, under directory /mw-android-friendica-01/src/de/wikilab/android/friendica01/.
Source file: TwAjax.java

public IgnoreCertsSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 3
From project BombusLime, under directory /src/org/bombusim/networking/.
Source file: AndroidSSLSocketFactory.java

public AndroidSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 4
From project cloudify, under directory /rest-client/src/main/java/org/cloudifysource/restclient/.
Source file: RestSSLSocketFactory.java

/** * Ctor. * @param truststore a {@link KeyStore} containing one or several trustedcertificates to enable server authentication. * @throws NoSuchAlgorithmException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws KeyManagementException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws KeyStoreException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. * @throws UnrecoverableKeyException Reporting failure to create SSLSocketFactory with the given trust-store and algorithm TLS or initialize the SSLContext. */ public RestSSLSocketFactory(final KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ @Override public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( final X509Certificate[] chain, final String authType) throws java.security.cert.CertificateException { } @Override public void checkServerTrusted( final X509Certificate[] chain, final String authType) throws java.security.cert.CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 5
From project dcm4che, under directory /dcm4che-net/src/main/java/org/dcm4che/net/.
Source file: Device.java

private TrustManager tm() throws GeneralSecurityException, IOException { TrustManager ret=tm; if (ret != null || trustStoreURL == null && authorizedNodeCertificates.isEmpty()) return ret; tm=ret=trustStoreURL != null ? SSLManagerFactory.createTrustManager(trustStoreType(),trustStoreURL,trustStorePin()) : SSLManagerFactory.createTrustManager(getAllAuthorizedNodeCertificates()); return ret; }
Example 6
From project LRJavaLib, under directory /src/com/navnorth/learningregistry/util/.
Source file: SelfSignSSLSocketFactory.java

public SelfSignSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 7
From project QuasselDroid, under directory /src/com/iskrembilen/quasseldroid/io/.
Source file: CustomTrustManager.java

CustomTrustManager(CoreConnection coreConnection) throws GeneralSecurityException { this.coreConnection=coreConnection; KeyStore ks=KeyStore.getInstance(KeyStore.getDefaultType()); TrustManagerFactory tmf=TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); tmf.init(ks); TrustManager tms[]=tmf.getTrustManagers(); for (int i=0; i < tms.length; i++) { if (tms[i] instanceof X509TrustManager) { defaultTrustManager=(X509TrustManager)tms[i]; return; } } throw new GeneralSecurityException("Couldn't initialize certificate management!"); }
Example 8
From project QuotaForAndroid, under directory /Quota/src/com/southfreo/quota/utils/.
Source file: OpenSSLFactory.java

public OpenSSLFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 9
From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/conn/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(truststore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 10
From project http-testing-harness, under directory /server-provider/src/test/java/org/sonatype/tests/http/server/jetty/behaviour/.
Source file: BehaviourSuiteConfiguration.java

private static void trustAllHttpsCertificates(){ SSLContext context; TrustManager[] _trustManagers=new TrustManager[]{new CustomTrustManager()}; try { context=SSLContext.getInstance("SSL"); context.init(null,_trustManagers,new SecureRandom()); } catch ( GeneralSecurityException gse) { throw new IllegalStateException(gse.getMessage()); } HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); }
Example 11
From project httpClient, under directory /httpclient/src/main/java/org/apache/http/conn/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(truststore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 12
From project JGlobus, under directory /ssl-proxies-tomcat/src/main/java/org/globus/gsi/tomcat/.
Source file: GlobusSSLSocketFactory.java

/** * Create a Globus trust manager which supports proxy certificates. This requires that the CRL store, and signing policy store be configured. * @param keystoreType The type of keystore to create. * @param keystoreProvider The keystore provider to use. * @param algorithm The keystore algorithm. * @return A set of configured TrustManagers. * @throws Exception If we cannot create the trust managers. */ @Override protected TrustManager[] getTrustManagers(String keystoreType,String keystoreProvider,String algorithm) throws Exception { KeyStore trustStore=getTrustStore(keystoreType,keystoreProvider); CertStore crlStore=null; Object crlLocation=attributes.get("crlLocation"); if (crlLocation != null) { crlStore=GlobusSSLHelper.findCRLStore((String)attributes.get("crlLocation")); } Object signingPolicyLocation=attributes.get("signingPolicyLocation"); ResourceSigningPolicyStore policyStore=null; if (signingPolicyLocation != null) { policyStore=new ResourceSigningPolicyStore(new ResourceSigningPolicyStoreParameters(attributes.get("signingPolicyLocation").toString())); } Object rejectLimitedProxyEntry=attributes.get("rejectLimitedProxy"); boolean rejectLimitedProxy=rejectLimitedProxyEntry != null && Boolean.parseBoolean(attributes.get("rejectLimitedProxy").toString()); X509ProxyCertPathParameters parameters=new X509ProxyCertPathParameters(trustStore,crlStore,policyStore,rejectLimitedProxy); TrustManager trustManager=new PKITrustManager(new X509ProxyCertPathValidator(),parameters); return new TrustManager[]{trustManager}; }
Example 13
From project nutch, under directory /src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/.
Source file: DummySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new DummyX509TrustManager(null)},null); return context; } catch ( Exception e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(),e); } throw new HttpClientError(e.toString()); } }
Example 14
From project subsonic, under directory /subsonic-android/src/github/daneren2005/dsub/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 15
From project Subsonic-Android, under directory /src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 16
From project subsonic_1, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 17
From project subsonic_2, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 18
From project Supersonic, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/service/ssl/.
Source file: SSLSocketFactory.java

private static SSLContext createSSLContext(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException { if (algorithm == null) { algorithm=TLS; } KeyManagerFactory kmfactory=KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmfactory.init(keystore,keystorePassword != null ? keystorePassword.toCharArray() : null); KeyManager[] keymanagers=kmfactory.getKeyManagers(); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); if (trustmanagers != null && trustStrategy != null) { for (int i=0; i < trustmanagers.length; i++) { TrustManager tm=trustmanagers[i]; if (tm instanceof X509TrustManager) { trustmanagers[i]=new TrustManagerDecorator((X509TrustManager)tm,trustStrategy); } } } SSLContext sslcontext=SSLContext.getInstance(algorithm); sslcontext.init(keymanagers,trustmanagers,random); return sslcontext; }
Example 19
From project websms-api, under directory /src/de/ub0r/android/websms/connector/common/.
Source file: FakeSocketFactory.java

/** * Create a {@link SSLContext}. * @return {@link SSLContext} * @throws IOException IOException */ private SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); final TrustManager trustManager; if (this.knownFingerprints == null) { trustManager=new FakeTrustManager(); } else { trustManager=new KnownFingerprintTrustManager(this.knownFingerprints); } context.init(null,new TrustManager[]{trustManager},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 20
From project YandexAPI, under directory /src/ru/elifantiev/yandex/.
Source file: YandexSSLSocketFactory.java

YandexSSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] certificates, String authType) throws CertificateException { for ( X509Certificate cert : certificates) cert.checkValidity(); } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 21
From project androidpn, under directory /androidpn-server-bin-tomcat/src/org/androidpn/server/xmpp/net/.
Source file: Connection.java

public void startTLS(ClientAuth authentication) throws Exception { log.debug("startTLS()..."); KeyStore ksKeys=SSLConfig.getKeyStore(); String keypass=SSLConfig.getKeyPassword(); KeyStore ksTrust=SSLConfig.getc2sTrustStore(); String trustpass=SSLConfig.getc2sTrustPassword(); KeyManager[] km=SSLKeyManagerFactory.getKeyManagers(ksKeys,keypass); TrustManager[] tm=SSLTrustManagerFactory.getTrustManagers(ksTrust,trustpass); SSLContext tlsContext=SSLContext.getInstance("TLS"); tlsContext.init(km,tm,null); SslFilter filter=new SslFilter(tlsContext); ioSession.getFilterChain().addFirst("tls",filter); ioSession.setAttribute(SslFilter.DISABLE_ENCRYPTION_ONCE,Boolean.TRUE); deliverRawText("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>"); }
Example 22
From project nuxeo-services, under directory /nuxeo-platform-directory/nuxeo-platform-directory-ldap/src/main/java/org/nuxeo/ecm/directory/ldap/.
Source file: LDAPDirectory.java

/** * Create a new SSLSocketFactory that creates a Socket regardless of the certificate used. * @throws SSLException if initialization fails. */ public TrustingSSLSocketFactory(){ try { SSLContext sslContext=SSLContext.getInstance("TLS"); sslContext.init(null,new TrustManager[]{new TrustingX509TrustManager()},new SecureRandom()); factory=sslContext.getSocketFactory(); } catch ( NoSuchAlgorithmException nsae) { throw new RuntimeException("Unable to initialize the SSL context: ",nsae); } catch ( KeyManagementException kme) { throw new RuntimeException("Unable to register a trust manager: ",kme); } }
Example 23
From project OAK, under directory /oak-library/src/main/java/oak/external/com/github/droidfu/http/ssl/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 24
From project activemq-apollo, under directory /apollo-util/src/main/scala/org/apache/activemq/apollo/util/.
Source file: SslContext.java

public SslContext(KeyManager[] km,TrustManager[] tm,SecureRandom random){ if (km != null) { setKeyManagers(Arrays.asList(km)); } if (tm != null) { setTrustManagers(Arrays.asList(tm)); } setSecureRandom(random); }
Example 25
From project android-bankdroid, under directory /src/eu/nullbyte/android/urllib/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 26
From project avro, under directory /lang/java/ipc/src/test/java/org/apache/avro/ipc/.
Source file: TestNettyServerWithSSL.java

@Override public SocketChannel newChannel(ChannelPipeline pipeline){ try { SSLContext sslContext=SSLContext.getInstance("TLS"); sslContext.init(null,new TrustManager[]{new BogusTrustManager()},null); SSLEngine sslEngine=sslContext.createSSLEngine(); sslEngine.setUseClientMode(true); pipeline.addFirst("ssl",new SslHandler(sslEngine)); return super.newChannel(pipeline); } catch ( Exception ex) { throw new RuntimeException("Cannot create SSL channel",ex); } }
Example 27
From project bbb-java, under directory /src/main/java/org/transdroid/util/.
Source file: FakeSocketFactory.java

private static SSLContext createEasySSLContext(String certKey) throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new FakeTrustManager(certKey)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 28
From project Bit4Tat, under directory /Bit4Tat/src/com/Bit4Tat/.
Source file: PaymentProcessorForMtGox.java

HttpsURLConnection setupConnection(String urlString){ SSLContext ctx=null; try { ctx=SSLContext.getInstance("TLS"); } catch ( NoSuchAlgorithmException e1) { e1.printStackTrace(); } try { ctx.init(new KeyManager[0],new TrustManager[]{new DefaultTrustManager()},new SecureRandom()); } catch ( KeyManagementException e) { e.printStackTrace(); } SSLContext.setDefault(ctx); URL url=null; try { url=new URL(urlString); } catch ( MalformedURLException e) { e.printStackTrace(); } HttpsURLConnection conn=null; try { conn=(HttpsURLConnection)url.openConnection(); } catch ( IOException e1) { e1.printStackTrace(); } conn.setDoOutput(true); conn.setDoInput(true); conn.setHostnameVerifier(new HostnameVerifier(){ @Override public boolean verify( String arg0, SSLSession arg1){ return true; } } ); return conn; }
Example 29
From project bitfluids, under directory /src/test/java/at/bitcoin_austria/bitfluids/.
Source file: NetTest.java

public static HttpClient wrapClient(HttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ @Override public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx); ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",ssf,443)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { throw new RuntimeException(ex); } }
Example 30
From project caseconductor-platform, under directory /utest-domain-services/src/main/java/com/utest/domain/service/util/.
Source file: TrustedSSLUtil.java

private static SSLContext createSSLContext(){ try { final SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{trustAllCerts},null); return context; } catch ( final Exception e) { throw new HttpClientError(e.toString()); } }
Example 31
From project cloudbees-api-client, under directory /cloudbees-api-client/src/main/java/com/cloudbees/api/.
Source file: TrustAllSocketFactory.java

public static SSLSocketFactory create(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] x509Certificates, String authType) throws CertificateException { if (LOGGER.isLoggable(FINE)) LOGGER.fine("Got the certificate: " + Arrays.asList(x509Certificates)); } public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } } },new SecureRandom()); return context.getSocketFactory(); } catch ( NoSuchAlgorithmException e) { throw new Error(e); } catch ( KeyManagementException e) { throw new Error(e); } }
Example 32
From project cmsandroid, under directory /src/com/zia/freshdocs/net/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 33
From project components-ness-httpclient, under directory /client/src/main/java/com/nesscomputing/httpclient/factory/httpclient4/.
Source file: ApacheHttpClient4Factory.java

public ApacheHttpClient4Factory(final HttpClientDefaults clientDefaults,@Nullable final Set<? extends HttpClientObserver> httpClientObservers){ Preconditions.checkArgument(clientDefaults != null,"clientDefaults can not be null!"); this.httpClientObservers=httpClientObservers; initParams(); registry.register(HTTP_SCHEME); try { final TrustManager[] trustManagers=new TrustManager[]{getTrustManager(clientDefaults)}; final KeyManager[] keyManagers=getKeyManagers(clientDefaults); final SSLContext sslContext=SSLContext.getInstance("TLS"); sslContext.init(keyManagers,trustManagers,null); final SSLSocketFactory sslSocketFactory=new SSLSocketFactory(sslContext); registry.register(new Scheme("https",HTTPS_PORT,sslSocketFactory)); } catch ( GeneralSecurityException ce) { throw new IllegalStateException(ce); } catch ( IOException ioe) { throw new IllegalStateException(ioe); } connectionManager=new ThreadSafeClientConnManager(registry); }
Example 34
From project cp-common-utils, under directory /src/com/clarkparsia/common/net/.
Source file: BasicX509TrustManager.java

public BasicX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keystore); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("no trust manager found"); } mDefaultTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 35
From project dreamDroid, under directory /src/net/reichholf/dreamdroid/helpers/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 36
From project droid-fu, under directory /src/main/java/com/github/droidfu/http/ssl/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 37
From project ereviewboard, under directory /org.review_board.ereviewboard.core/src/org/apache/commons/httpclient/contrib/ssl/.
Source file: EasySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new HttpClientError(e.toString()); } }
Example 38
From project evodroid, under directory /src/com/sonorth/evodroid/util/.
Source file: TrustAllSSLSocketFactory.java

public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { super(null); try { SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,new TrustManager[]{new TrustAllManager()},null); factory=sslcontext.getSocketFactory(); setHostnameVerifier(new AllowAllHostnameVerifier()); } catch ( Exception ex) { } }
Example 39
From project groundhog-reader, under directory /src/main/java/com/almarsoft/GroundhogReader/lib/.
Source file: TrustManagerFactory.java

public static X509TrustManager get(String host,boolean secure) throws NoSuchAlgorithmException { if (secure) { String defaultAlgorithm=javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm(); javax.net.ssl.TrustManagerFactory tmf=javax.net.ssl.TrustManagerFactory.getInstance(defaultAlgorithm); TrustManager[] tms=tmf.getTrustManagers(); return new SecureX509TrustManager((X509TrustManager)tms[0],host); } else { return sUnsecureTrustManager; } }
Example 40
From project heritrix3, under directory /commons/src/main/java/org/archive/httpclient/.
Source file: ConfigurableX509TrustManager.java

/** * Constructor. * @param level Level of trust to effect. * @throws NoSuchAlgorithmException * @throws KeyStoreException */ public ConfigurableX509TrustManager(TrustLevel level) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init((KeyStore)null); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException(TrustManagerFactory.getDefaultAlgorithm() + " trust manager not supported"); } this.standardTrustManager=(X509TrustManager)trustmanagers[0]; this.trustLevel=level; }
Example 41
From project httpcore, under directory /httpcore-nio/src/test/java/org/apache/http/impl/nio/reactor/.
Source file: TestBaseIOReactorSSL.java

@Test public void testBufferedInput() throws Exception { final int[] result=new int[1]; HttpRequestHandler requestHandler=new HttpRequestHandler(){ public void handle( HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { result[0]++; synchronized (result) { result.notify(); } } } ; NHttpServiceHandler serviceHandler=createHttpServiceHandler(requestHandler,null,null); this.server.start(serviceHandler); ClassLoader cl=getClass().getClassLoader(); URL url=cl.getResource("test.keystore"); KeyStore keystore=KeyStore.getInstance("jks"); keystore.load(url.openStream(),"nopassword".toCharArray()); TrustManagerFactory tmfactory=createTrustManagerFactory(); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,trustmanagers,null); ListenerEndpoint endpoint=this.server.getListenerEndpoint(); endpoint.waitFor(); InetSocketAddress serverAddress=(InetSocketAddress)endpoint.getAddress(); Socket socket=sslcontext.getSocketFactory().createSocket("localhost",serverAddress.getPort()); BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); writer.write("GET / HTTP/1.1\r\n"); writer.write("Header: \r\n"); writer.write("Header: \r\n"); writer.write("Header: \r\n"); writer.write("\r\n"); writer.flush(); synchronized (result) { result.wait(500); } Assert.assertEquals(1,result[0]); }
Example 42
From project ignition, under directory /ignition-support/ignition-support-lib/src/main/java/com/github/ignition/support/http/ssl/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 43
From project iSpace, under directory /base/httpcrawler/src/main/java/com/villemos/ispace/httpcrawler/.
Source file: EasyX509TrustManager.java

/** * Constructor for EasyX509TrustManager. */ public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); factory.init(keystore); TrustManager[] trustmanagers=factory.getTrustManagers(); if (trustmanagers.length == 0) { throw new NoSuchAlgorithmException("no trust manager found"); } this.standardTrustManager=(X509TrustManager)trustmanagers[0]; }
Example 44
From project jentrata-msh, under directory /Commons/src/main/java/hk/hku/cecid/piazza/commons/net/.
Source file: HttpConnector.java

/** * Sets the default key manager and trust manager. This method will look up module components of key manager (id: ssl-key-manager) and trust manager (id: ssl-trust-manager) in the system main module. */ private void setDefaultManagers(){ Component keyman=Sys.main.getComponent("ssl-key-manager"); Component trustman=Sys.main.getComponent("ssl-trust-manager"); if (keyman != null && keyman instanceof KeyManager) { addKeyManager((KeyManager)keyman); } if (trustman != null && trustman instanceof TrustManager) { addTrustManager((TrustManager)trustman); } }
Example 45
From project jupload, under directory /src/wjhk/jupload2/upload/.
Source file: InteractiveTrustManager.java

/** * @see javax.net.ssl.X509TrustManager#checkServerTrusted(java.security.cert.X509Certificate[],java.lang.String) */ public void checkServerTrusted(X509Certificate[] chain,String authType) throws CertificateException { if ((this.mode & SERVER) != 0) { if (null == chain || chain.length == 0) throw new IllegalArgumentException("Certificate chain is null or empty"); int i; TrustManager[] mgrs=this.tmf.getTrustManagers(); for (i=0; i < mgrs.length; i++) { if (mgrs[i] instanceof X509TrustManager) { X509TrustManager m=(X509TrustManager)(mgrs[i]); try { m.checkServerTrusted(chain,authType); return; } catch ( Exception e) { } } } CertDialog(chain[0]); } }
Example 46
From project k-9, under directory /src/com/fsck/k9/mail/transport/.
Source file: TrustedSocketFactory.java

public TrustedSocketFactory(String host,boolean secure) throws NoSuchAlgorithmException, KeyManagementException { SSLContext sslContext=SSLContext.getInstance("TLS"); sslContext.init(null,new TrustManager[]{TrustManagerFactory.get(host,secure)},new SecureRandom()); mSocketFactory=sslContext.getSocketFactory(); mSchemeSocketFactory=org.apache.http.conn.ssl.SSLSocketFactory.getSocketFactory(); mSchemeSocketFactory.setHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); }
Example 47
From project Kairos, under directory /src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/.
Source file: DummySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new DummyX509TrustManager(null)},null); return context; } catch ( Exception e) { if (LOG.isErrorEnabled()) { LOG.error(e.getMessage(),e); } throw new HttpClientError(e.toString()); } }
Example 48
From project karaf, under directory /jaas/config/src/main/java/org/apache/karaf/jaas/config/impl/.
Source file: ResourceKeystoreInstance.java

public TrustManager[] getTrustManager(String algorithm) throws KeyStoreException, NoSuchAlgorithmException, KeystoreIsLocked { if (isKeystoreLocked()) { throw new KeystoreIsLocked("Keystore '" + name + "' is locked."); } if (!loadKeystoreData()) { return null; } TrustManagerFactory trustFactory=TrustManagerFactory.getInstance(algorithm); trustFactory.init(keystore); return trustFactory.getTrustManagers(); }
Example 49
From project litle-sdk-for-java, under directory /lib/apache-cxf-2.5.2/samples/jax_rs/basic_https/src/main/java/org/apache/commons/httpclient/contrib/ssl/.
Source file: AuthSSLProtocolSocketFactory.java

private static TrustManager[] createTrustManagers(final KeyStore keystore) throws KeyStoreException, NoSuchAlgorithmException { if (keystore == null) { throw new IllegalArgumentException("Keystore may not be null"); } LOG.debug("Initializing trust manager"); TrustManagerFactory tmfactory=TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); tmfactory.init(keystore); TrustManager[] trustmanagers=tmfactory.getTrustManagers(); for (int i=0; i < trustmanagers.length; i++) { if (trustmanagers[i] instanceof X509TrustManager) { trustmanagers[i]=new AuthSSLX509TrustManager((X509TrustManager)trustmanagers[i]); } } return trustmanagers; }
Example 50
private void startupSSL(){ try { System.setProperty("java.protocol.handler.pkgs","javax.net.ssl"); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; SSLContext sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String urlHostName, SSLSession session){ return true; } } ; HttpsURLConnection.setDefaultHostnameVerifier(hv); } catch ( Exception e) { console.output("! " + e.getMessage() + "\n",true); } }
Example 51
public static void allowAllSSL(){ HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){ public boolean verify( String hostname, SSLSession session){ return true; } } ); if (trustManagers == null) { trustManagers=new TrustManager[]{new FakeX509TrustManager()}; } try { context=SSLContext.getInstance("TLS"); context.init(null,trustManagers,new SecureRandom()); } catch ( NoSuchAlgorithmException e) { e.printStackTrace(); } catch ( KeyManagementException e) { e.printStackTrace(); } HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); }
Example 52
From project lyo.testsuite, under directory /org.eclipse.lyo.testsuite.server/src/main/java/org/eclipse/lyo/testsuite/server/util/.
Source file: OSLCUtils.java

static public void setupLazySSLSupport(HttpClient httpClient){ ClientConnectionManager connManager=httpClient.getConnectionManager(); SchemeRegistry schemeRegistry=connManager.getSchemeRegistry(); schemeRegistry.unregister("https"); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } } }; SSLContext sc=null; try { sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); } catch ( NoSuchAlgorithmException e) { } catch ( KeyManagementException e) { } SSLSocketFactory sf=new SSLSocketFactory(sc); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme https=new Scheme("https",sf,443); schemeRegistry.register(https); }
Example 53
From project Maimonides, under directory /src/com/codeko/apps/maimonides/seneca/.
Source file: ClienteSeneca.java

public HttpClient getCliente(){ if (cliente == null) { try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ @Override public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry schemeRegistry=new SchemeRegistry(); schemeRegistry.register(new Scheme("http",80,PlainSocketFactory.getSocketFactory())); schemeRegistry.register(new Scheme("https",443,ssf)); HttpParams params=new BasicHttpParams(); HttpProtocolParams.setUserAgent(params,"Mozilla/5.0 (X11; U; Linux i686; es-ES; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.6.12"); ThreadSafeClientConnManager cm=new ThreadSafeClientConnManager(schemeRegistry); cm.setDefaultMaxPerRoute(10); cm.setMaxTotal(20); HttpConnectionParams.setConnectionTimeout(params,1000); cliente=new DefaultHttpClient(cm,params); } catch ( Exception ex) { Logger.getLogger(ClienteSeneca.class.getName()).log(Level.SEVERE,null,ex); setUltimoError("Error conectando con S?neca: " + ex.getLocalizedMessage()); setUltimaExcepcion(ex); } } ThreadSafeClientConnManager man=(ThreadSafeClientConnManager)cliente.getConnectionManager(); man.closeExpiredConnections(); man.closeIdleConnections(10,TimeUnit.SECONDS); Logger.getLogger(ClienteSeneca.class.getName()).log(Level.INFO,"Hay {0} conexiones abiertas.",man.getConnectionsInPool()); return cliente; }
Example 54
From project maven-wagon, under directory /wagon-providers/wagon-http-shared4/src/main/java/org/apache/maven/wagon/shared/http4/.
Source file: EasyX509TrustManager.java

protected static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { IOException ioe=new IOException(e.getMessage()); ioe.initCause(e); throw ioe; } }
Example 55
From project micromailer, under directory /src/main/java/org/sonatype/micromailer/imp/.
Source file: AbstractDebugSecureSocketFactory.java

public AbstractDebugSecureSocketFactory(String protocol){ try { SSLContext sslcontext=SSLContext.getInstance(protocol); sslcontext.init(null,new TrustManager[]{new NaiveTrustManager()},null); factory=(SSLSocketFactory)sslcontext.getSocketFactory(); } catch ( Exception ex) { } }
Example 56
From project miso-lims, under directory /core/src/main/java/uk/ac/bbsrc/tgac/miso/core/manager/.
Source file: ERASubmissionManager.java

/** * Builds a "trusting" trust manager. This is totally horrible and basically ignores everything that SSL stands for. This allows connection to self-signed certificate hosts, bypassing the normal validation exceptions that occur. <p/> Use at your own risk - again, this is horrible! */ public DefaultHttpClient getEvilTrustingTrustManager(DefaultHttpClient httpClient){ try { X509TrustManager trustManager=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { log.warn("BYPASSING CLIENT TRUSTED CHECK!"); } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { log.warn("BYPASSING SERVER TRUSTED CHECK!"); } public X509Certificate[] getAcceptedIssuers(){ log.warn("BYPASSING CERTIFICATE ISSUER CHECKS!"); return null; } } ; SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,new TrustManager[]{trustManager},null); SSLSocketFactory sf=new SSLSocketFactory(sslcontext); sf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=httpClient.getConnectionManager(); SchemeRegistry schemeRegistry=ccm.getSchemeRegistry(); schemeRegistry.register(new Scheme("https",sf,443)); return new DefaultHttpClient(ccm,httpClient.getParams()); } catch ( Throwable t) { log.warn("Something nasty happened with the EvilTrustingTrustManager. Warranty is null and void!"); t.printStackTrace(); return null; } }
Example 57
From project MobiPerf, under directory /android/src/com/mobiperf/speedometer/.
Source file: Checkin.java

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 58
From project OpenConext-api, under directory /coin-api-war/src/main/java/nl/surfnet/coin/api/playground/.
Source file: OAuthRequestIgnoreCertificate.java

private void createUnsafeConnection() throws Exception { System.setProperty("http.keepAlive","true"); String completeUrl=getCompleteUrl(); Field connField=getClass().getSuperclass().getSuperclass().getDeclaredField("connection"); connField.setAccessible(true); TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; SSLContext sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); URLConnection openConnection=new URL(completeUrl).openConnection(); connField.set(this,openConnection); }
Example 59
From project OpenMEAP, under directory /java-shared/openmeap-shared-jdk5/src/com/openmeap/util/.
Source file: SSLUtils.java

/** * @param keyStore is passed into TrustManagerFactory.init(), and may be null for default behavior. * @return an array of the default trust managers * @throws NoSuchAlgorithmException * @throws KeyStoreException */ public static TrustManager[] getDefaultTrustManagers(KeyStore keyStore) throws NoSuchAlgorithmException, KeyStoreException { String defaultFactoryManagerAlg=TrustManagerFactory.getDefaultAlgorithm(); TrustManagerFactory managerFactory=TrustManagerFactory.getInstance(defaultFactoryManagerAlg); managerFactory.init((KeyStore)keyStore); return managerFactory.getTrustManagers(); }
Example 60
From project openshift-java-client, under directory /src/main/java/com/openshift/internal/client/httpclient/.
Source file: UrlConnectionHttpClient.java

/** * Sets a trust manager that will always trust. <p> TODO: dont swallog exceptions and setup things so that they dont disturb other components. */ private void setPermissiveSSLSocketFactory(HttpsURLConnection connection){ try { SSLContext sslContext=SSLContext.getInstance("SSL"); sslContext.init(new KeyManager[0],new TrustManager[]{new PermissiveTrustManager()},new SecureRandom()); SSLSocketFactory socketFactory=sslContext.getSocketFactory(); ((HttpsURLConnection)connection).setSSLSocketFactory(socketFactory); } catch ( KeyManagementException e) { } catch ( NoSuchAlgorithmException e) { } }
Example 61
From project Orweb, under directory /src/info/guardianproject/browser/.
Source file: ModSSLSocketFactory.java

public ModSSLSocketFactory(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final HostNameResolver nameResolver) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(); if (algorithm == null) { algorithm=TLS; } KeyManager[] keymanagers=null; if (keystore != null) { keymanagers=createKeyManagers(keystore,keystorePassword); } TrustManager[] trustmanagers=null; if (truststore != null) { trustmanagers=createTrustManagers(truststore); } this.sslcontext=SSLContext.getInstance(algorithm); this.sslcontext.init(keymanagers,trustmanagers,random); this.socketfactory=this.sslcontext.getSocketFactory(); this.nameResolver=nameResolver; }
Example 62
From project osgi-tests, under directory /test/glassfish-derby/src/test/java/org/ancoron/osgi/test/glassfish/.
Source file: GlassfishDerbyTest.java

protected DefaultHttpClient getHTTPClient() throws NoSuchAlgorithmException, KeyManagementException { SSLContext sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{new X509TrustManager(){ @Override public X509Certificate[] getAcceptedIssuers(){ System.out.println("getAcceptedIssuers ============="); return null; } @Override public void checkClientTrusted( X509Certificate[] certs, String authType){ System.out.println("checkClientTrusted ============="); } @Override public void checkServerTrusted( X509Certificate[] certs, String authType){ System.out.println("checkServerTrusted ============="); } } },new SecureRandom()); SSLSocketFactory sf=new SSLSocketFactory(sslContext,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); Scheme httpsScheme=new Scheme("https",8181,sf); PlainSocketFactory plain=new PlainSocketFactory(); Scheme httpScheme=new Scheme("http",8080,plain); SchemeRegistry schemeRegistry=new SchemeRegistry(); schemeRegistry.register(httpsScheme); schemeRegistry.register(httpScheme); HttpParams params=new BasicHttpParams(); ThreadSafeClientConnManager cm=new ThreadSafeClientConnManager(schemeRegistry); cm.setMaxTotal(200); cm.setDefaultMaxPerRoute(20); DefaultHttpClient httpClient=new DefaultHttpClient(cm,params); httpClient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION,HttpVersion.HTTP_1_1); httpClient.getParams().setParameter(CoreProtocolPNames.HTTP_CONTENT_CHARSET,"UTF-8"); return httpClient; }
Example 63
From project PenguinCMS, under directory /PenguinCMS/tests/vendor/sahi/src/net/sf/sahi/ssl/.
Source file: SSLHelper.java

public static TrustManager[] getAllTrustingManager(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; return trustAllCerts; }
Example 64
/** * This function will install a trust manager that will blindly trust all SSL certificates. The reason this code is being added is to enable developers to do development using self signed SSL certificates on their web server. The standard HttpsURLConnection class will throw an exception on self signed certificates if this code is not run. */ private void trustAllHosts(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return new java.security.cert.X509Certificate[]{}; } public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } }; try { defaultSSLSocketFactory=HttpsURLConnection.getDefaultSSLSocketFactory(); SSLContext sc=SSLContext.getInstance("TLS"); sc.init(null,trustAllCerts,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch ( Exception e) { System.out.println(e.getMessage()); } }
Example 65
From project Pitbull, under directory /pitbull-core/src/main/java/org/jboss/pitbull/client/.
Source file: HttpConnectionFactory.java

public static ClientConnection https(String host,int port,long timeout,TimeUnit unit) throws IOException { java.lang.System.setProperty("sun.security.ssl.allowUnsafeRenegotiation","true"); X509TrustManager trustManager=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; SSLContext sslContext=null; try { sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{trustManager},new SecureRandom()); SSLEngine engine=sslContext.createSSLEngine(); engine.setUseClientMode(true); SocketChannel channel=createSocket(host,port,timeout,unit); ClientSSLChannel sslChannel=new ClientSSLChannel(channel,engine); return new ClientConnectionImpl(sslChannel,host,port); } catch ( Exception e) { throw new RuntimeException(e); } }
Example 66
From project platform_external_apache-http, under directory /src/org/apache/http/conn/ssl/.
Source file: SSLSocketFactory.java

public SSLSocketFactory(String algorithm,final KeyStore keystore,final String keystorePassword,final KeyStore truststore,final SecureRandom random,final HostNameResolver nameResolver) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(); if (algorithm == null) { algorithm=TLS; } KeyManager[] keymanagers=null; if (keystore != null) { keymanagers=createKeyManagers(keystore,keystorePassword); } TrustManager[] trustmanagers=null; if (truststore != null) { trustmanagers=createTrustManagers(truststore); } this.sslcontext=SSLContext.getInstance(algorithm); this.sslcontext.init(keymanagers,trustmanagers,random); this.socketfactory=this.sslcontext.getSocketFactory(); this.nameResolver=nameResolver; }
Example 67
From project portal, under directory /portal-core/src/main/java/org/devproof/portal/core/module/common/util/httpclient/ssl/.
Source file: EasySSLProtocolSocketFactory.java

private static SSLContext createEasySSLContext(){ try { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { logger.error(e.getMessage(),e); throw new HttpClientError(e.toString()); } }
Example 68
From project processFlowProvision, under directory /osProvision/src/main/java/org/jboss/processFlow/openshift/.
Source file: ShifterProvisioner.java

private void prepConnection() throws Exception { httpClient=new DefaultHttpClient(); SSLContext sslContext=SSLContext.getInstance("SSL"); sslContext.init(null,new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ System.out.println("getAcceptedIssuers ============="); return null; } public void checkClientTrusted( X509Certificate[] certs, String authType){ System.out.println("checkClientTrusted ============="); } public void checkServerTrusted( X509Certificate[] certs, String authType){ System.out.println("checkServerTrusted ============="); } } },new SecureRandom()); SSLSocketFactory ssf=new SSLSocketFactory(sslContext,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=httpClient.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); UsernamePasswordCredentials credentials=new UsernamePasswordCredentials(accountId,password); URL urlObj=new URL(openshiftRestURI); AuthScope aScope=new AuthScope(urlObj.getHost(),urlObj.getPort()); httpClient.getCredentialsProvider().setCredentials(aScope,credentials); httpClient.addRequestInterceptor(new PreemptiveAuthInterceptor(),0); }
Example 69
From project proxydroid, under directory /src/com/github/droidfu/http/ssl/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new TrivialTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 70
From project rain-workload-toolkit, under directory /src/radlab/rain/util/.
Source file: HttpTransport.java

public static HttpClient wrapClient(HttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { return null; } }
Example 71
From project recordloader, under directory /src/java/com/marklogic/recordloader/xcc/.
Source file: XccConfiguration.java

protected static SecurityOptions newTrustAnyoneOptions() throws KeyManagementException, NoSuchAlgorithmException { TrustManager[] trust=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } /** * @throws CertificateException */ public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { } /** * @throws CertificateException */ public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType) throws CertificateException { } } }; SSLContext sslContext=SSLContext.getInstance("SSLv3"); sslContext.init(null,trust,null); return new SecurityOptions(sslContext); }
Example 72
From project ReGalAndroid, under directory /g2-java-client/src/main/java/net/dahanne/gallery/g2/java/client/ssl/.
Source file: FakeSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new FakeTrustManager()},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 73
From project remoting, under directory /src/main/java/hudson/remoting/.
Source file: Launcher.java

/** * Bypass HTTPS security check by using free-for-all trust manager. * @param _ This is ignored. */ @Option(name="-noCertificateCheck") public void setNoCertificateCheck(boolean _) throws NoSuchAlgorithmException, KeyManagementException { System.out.println("Skipping HTTPS certificate checks altoghether. Note that this is not secure at all."); SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new NoCheckTrustManager()},new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier(){ public boolean verify( String s, SSLSession sslSession){ return true; } } ); }
Example 74
From project repose, under directory /project-set/commons/utilities/src/main/java/com/rackspace/papi/commons/util/http/.
Source file: HttpsURLConnectionSslInitializer.java

public void allowAllServerCerts(){ TrustManager[] trustAllCerts=new TrustManager[]{new TrustingX509TrustManager()}; try { final SSLContext sc=SSLContext.getInstance("SSL"); sc.init(null,trustAllCerts,new SecureRandom()); SSLContext.setDefault(sc); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); } catch ( Exception e) { LOG.error("Problem creating SSL context: ",e); } }
Example 75
From project rest-client, under directory /src/main/java/org/hudsonci/rest/client/internal/ssl/.
Source file: TrustAllX509TrustManager.java

public static synchronized void install() throws KeyManagementException, NoSuchAlgorithmException { SSLContext context=SSLContext.getInstance("SSL"); context.init(null,new TrustManager[]{new TrustAllX509TrustManager()},new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(context.getSocketFactory()); log.warn("Trust-all SSL trust manager installed"); }
Example 76
From project restfuse, under directory /com.eclipsesource.restfuse/src/com/github/kevinsawicki/http/.
Source file: HttpRequest.java

private static SSLSocketFactory getTrustedFactory() throws HttpRequestException { if (TRUSTED_FACTORY == null) { final TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } public void checkClientTrusted( X509Certificate[] chain, String authType){ } public void checkServerTrusted( X509Certificate[] chain, String authType){ } } }; try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,trustAllCerts,new SecureRandom()); TRUSTED_FACTORY=context.getSocketFactory(); } catch ( GeneralSecurityException e) { IOException ioException=new IOException("Security exception configuring SSL context"); ioException.initCause(e); throw new HttpRequestException(ioException); } } return TRUSTED_FACTORY; }
Example 77
From project Rhybudd, under directory /src/net/networksaremadeofstring/rhybudd/.
Source file: TrustAllSSLSocketFactory.java

public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { super(null); try { SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,new TrustManager[]{new TrustAllManager()},null); factory=sslcontext.getSocketFactory(); setHostnameVerifier(new AllowAllHostnameVerifier()); } catch ( Exception ex) { } }
Example 78
private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 79
From project samples_3, under directory /im/src/main/java/ga/im/xmpp/.
Source file: XMPPConnectionManager.java

private void startTlsConnection(){ try { connected=false; connection.stop(); final SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new FakeTrustManager()},null); Socket plain=socket; socket=context.getSocketFactory().createSocket(plain,plain.getInetAddress().getHostName(),plain.getPort(),true); socket.setSoTimeout(0); socket.setKeepAlive(true); ((SSLSocket)socket).startHandshake(); Thread.sleep(1000); connection.start(); } catch ( Exception e) { throw new XMPPException("Can not start TLS connection",e); } }
Example 80
From project sandbox, under directory /xeclipse/org.xwiki.eclipse.core/src/main/java/org/xwiki/eclipse/core/.
Source file: CorePlugin.java

public void start(BundleContext context) throws Exception { super.start(context); plugin=this; TrustManager[] trustAllCertificates=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } } }; SSLContext sc=SSLContext.getInstance("SSL"); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String arg0, SSLSession arg1){ return true; } } ; sc.init(null,trustAllCertificates,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
Example 81
From project sensei, under directory /sensei-core/src/main/java/com/senseidb/dataprovider/http/.
Source file: HttpsClientDecorator.java

public static DefaultHttpClient decorate(DefaultHttpClient base){ try { SSLContext ctx=SSLContext.getInstance("TLS"); X509TrustManager tm=new X509TrustManager(){ public void checkClientTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public void checkServerTrusted( X509Certificate[] xcs, String string) throws CertificateException { } public X509Certificate[] getAcceptedIssuers(){ return null; } } ; ctx.init(null,new TrustManager[]{tm},null); SSLSocketFactory ssf=new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); ClientConnectionManager ccm=base.getConnectionManager(); SchemeRegistry sr=ccm.getSchemeRegistry(); sr.register(new Scheme("https",443,ssf)); return new DefaultHttpClient(ccm,base.getParams()); } catch ( Exception ex) { logger.error(ex.getMessage(),ex); return null; } }
Example 82
From project sisu-litmus, under directory /litmus-testsupport/src/main/java/org/sonatype/sisu/litmus/testsupport/net/.
Source file: SSLUtil.java

public static void trustEveryone(){ try { SSLContext context=SSLContext.getInstance("SSL"); TrustManager[] tm=new TrustManager[]{new TrustingX509TrustManager()}; context.init(null,tm,null); SSLContext.setDefault(context); } catch ( Exception e) { Throwables.propagate(e); } }
Example 83
From project skalli, under directory /org.eclipse.skalli.core/src/main/java/org/eclipse/skalli/core/internal/destination/.
Source file: DestinationServiceImpl.java

private void initializeConnectionManager(){ connectionManager=new ThreadSafeClientConnManager(); connectionManager.setMaxTotal(MAX_TOTAL_CONNECTIONS); connectionManager.setDefaultMaxPerRoute(MAX_CONNECTIONS_PER_ROUTE); SSLContext sslContext=getSSLContext(); try { sslContext.init(null,new TrustManager[]{new AlwaysTrustX509Manager()},null); } catch ( KeyManagementException e) { throw new IllegalStateException("Failed to initialize SSL context",e); } SSLSocketFactory socketFactory=new SSLSocketFactory(sslContext,new AllowAllHostnamesVerifier()); SchemeRegistry schemeRegistry=connectionManager.getSchemeRegistry(); schemeRegistry.register(new Scheme(HTTPS,443,socketFactory)); }
Example 84
From project SMSSync, under directory /smssync/src/org/addhen/smssync/net/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 85
From project snacktory, under directory /src/main/java/de/jetwick/snacktory/.
Source file: SHelper.java

public static void enableAnySSL(){ try { SSLContext ctx=SSLContext.getInstance("TLS"); ctx.init(new KeyManager[0],new TrustManager[]{new DefaultTrustManager()},new SecureRandom()); SSLContext.setDefault(ctx); } catch ( Exception ex) { ex.printStackTrace(); } }
Example 86
From project Speedometer, under directory /android/src/com/google/wireless/speed/speedometer/.
Source file: Checkin.java

public MySSLSocketFactory(KeyStore truststore) throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException { super(truststore); X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } @Override public void checkClientTrusted( X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkServerTrusted( X509Certificate[] chain, String authType) throws CertificateException { } } ; sslContext.init(null,new TrustManager[]{tm},null); }
Example 87
From project SVQCOM, under directory /Core/src/com/ushahidi/android/app/net/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 88
From project syplod, under directory /src/com/android/picasaphotouploader/.
Source file: GoogleAuthentication.java

/** * Try to get google authentication string for user e-mail and password. We need authentication string to authenticate uploads for images * @return Google authentication string */ public String getAuthenticationString(){ try { String authUrl="https://www.google.com/accounts/ClientLogin?accountType=GOOGLE&Email=" + email + "&Passwd="+ password+ "&service=lh2&source=PicasaUploader"; SSLContext sc=SSLContext.getInstance("TLS"); sc.init(null,new TrustManager[]{new MyTrustManager()},new SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(new MyHostnameVerifier()); HttpsURLConnection con=(HttpsURLConnection)new URL(authUrl).openConnection(); con.setReadTimeout(15000); con.setDoOutput(true); con.connect(); BufferedReader br=new BufferedReader(new InputStreamReader(con.getInputStream())); StringBuffer sb=new StringBuffer(); String line; while ((line=br.readLine()) != null) { sb.append(line); } String body=sb.toString(); Integer index=body.indexOf("Auth="); if (index != -1) { auth=body.substring(index + 5); } } catch ( Exception e) { e.printStackTrace(); } return auth; }
Example 89
From project TiVo-Commander, under directory /src/com/arantius/tivocommander/rpc/.
Source file: MindRpc.java

private static SSLSocketFactory createSocketFactory(final Activity originActivity){ final String password=readPassword(originActivity); try { KeyStore keyStore=KeyStore.getInstance("PKCS12"); KeyManagerFactory fac=KeyManagerFactory.getInstance("X509"); InputStream keyInput=originActivity.getResources().openRawResource(R.raw.cdata); keyStore.load(keyInput,password.toCharArray()); keyInput.close(); fac.init(keyStore,password.toCharArray()); SSLContext context=SSLContext.getInstance("TLS"); TrustManager[] tm=new TrustManager[]{new AlwaysTrustManager()}; context.init(fac.getKeyManagers(),tm,new SecureRandom()); return context.getSocketFactory(); } catch ( CertificateException e) { Log.e(LOG_TAG,"createSocketFactory: CertificateException!",e); } catch ( IOException e) { Log.e(LOG_TAG,"createSocketFactory: IOException!",e); } catch ( KeyManagementException e) { Log.e(LOG_TAG,"createSocketFactory: KeyManagementException!",e); } catch ( KeyStoreException e) { Log.e(LOG_TAG,"createSocketFactory: KeyStoreException!",e); } catch ( NoSuchAlgorithmException e) { Log.e(LOG_TAG,"createSocketFactory: NoSuchAlgorithmException!",e); } catch ( UnrecoverableKeyException e) { Log.e(LOG_TAG,"createSocketFactory: UnrecoverableKeyException!",e); } return null; }
Example 90
From project twistDemo, under directory /twist-libs/com.thoughtworks.webdriver.recorder_1.0.0.11288/sahi/src/net/sf/sahi/ssl/.
Source file: SSLHelper.java

public static TrustManager[] getAllTrustingManager(){ TrustManager[] trustAllCerts=new TrustManager[]{new X509TrustManager(){ public java.security.cert.X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( java.security.cert.X509Certificate[] certs, String authType){ } public void checkServerTrusted( java.security.cert.X509Certificate[] certs, String authType){ } } }; return trustAllCerts; }
Example 91
From project twitter-2-weibo, under directory /core/src/main/java/weibo4j/model/.
Source file: MySSLSocketFactory.java

private SSLContext createSSLContext(){ SSLContext sslcontext=null; try { sslcontext=SSLContext.getInstance("SSL"); sslcontext.init(null,new TrustManager[]{new TrustAnyTrustManager()},new java.security.SecureRandom()); } catch ( NoSuchAlgorithmException e) { e.printStackTrace(); } catch ( KeyManagementException e) { e.printStackTrace(); } return sslcontext; }
Example 92
From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/net/.
Source file: EasySSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new EasyX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }
Example 93
From project WaarpCommon, under directory /src/main/java/org/waarp/common/crypto/ssl/.
Source file: WaarpSecureTrustManagerFactory.java

/** * Accept all connections */ public WaarpSecureTrustManagerFactory(){ ggTrustManager=new WaarpX509TrustManager(); trustManager=new TrustManager[]{ggTrustManager}; needAuthentication=false; hasTrustStore=false; }
Example 94
From project Weave, under directory /JTDS_SqlServerDriver/src/main/net/sourceforge/jtds/ssl/.
Source file: SocketFactories.java

private static TrustManager[] trustManagers(){ X509TrustManager tm=new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } public void checkServerTrusted( X509Certificate[] chain, String x){ } public void checkClientTrusted( X509Certificate[] chain, String x){ } } ; return new X509TrustManager[]{tm}; }
Example 95
From project Wordpress-Android-App, under directory /src/org/wordpress/android/util/.
Source file: TrustAllSSLSocketFactory.java

public TrustAllSSLSocketFactory() throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException { super(null); try { SSLContext sslcontext=SSLContext.getInstance("TLS"); sslcontext.init(null,new TrustManager[]{new TrustAllManager()},null); factory=sslcontext.getSocketFactory(); setHostnameVerifier(new AllowAllHostnameVerifier()); } catch ( Exception ex) { } }
Example 96
From project xnio_1, under directory /api/src/main/java/org/xnio/ssl/.
Source file: JsseSslUtils.java

/** * Create a new SSL context, configured from an option map and the given parameters. * @param keyManagers the key managers to use, or {@code null} to configure from the option map * @param trustManagers the trust managers to use, or {@code null} to configure from the option map * @param secureRandom the secure RNG to use, or {@code null} to choose a system default * @param optionMap the SSL context options * @return a new context * @throws NoSuchProviderException if there is no matching provider * @throws NoSuchAlgorithmException if there is no matching algorithm * @throws KeyManagementException if the context initialization fails */ public static SSLContext createSSLContext(KeyManager[] keyManagers,TrustManager[] trustManagers,SecureRandom secureRandom,OptionMap optionMap) throws NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException { final String provider=optionMap.get(Options.SSL_PROVIDER); final String protocol=optionMap.get(Options.SSL_PROTOCOL); final SSLContext sslContext; if (protocol == null) { return SSLContext.getDefault(); } else if (provider == null) { sslContext=SSLContext.getInstance(protocol); } else { sslContext=SSLContext.getInstance(protocol,provider); } if (keyManagers == null) { final Sequence<Class<? extends KeyManager>> keyManagerClasses=optionMap.get(Options.SSL_JSSE_KEY_MANAGER_CLASSES); if (keyManagerClasses != null) { final int size=keyManagerClasses.size(); keyManagers=new KeyManager[size]; for (int i=0; i < size; i++) { keyManagers[i]=instantiate(keyManagerClasses.get(i)); } } } if (trustManagers == null) { final Sequence<Class<? extends TrustManager>> trustManagerClasses=optionMap.get(Options.SSL_JSSE_TRUST_MANAGER_CLASSES); if (trustManagerClasses != null) { final int size=trustManagerClasses.size(); trustManagers=new TrustManager[size]; for (int i=0; i < size; i++) { trustManagers[i]=instantiate(trustManagerClasses.get(i)); } } } sslContext.init(keyManagers,trustManagers,secureRandom); sslContext.getClientSessionContext().setSessionCacheSize(optionMap.get(Options.SSL_CLIENT_SESSION_CACHE_SIZE,0)); sslContext.getClientSessionContext().setSessionTimeout(optionMap.get(Options.SSL_CLIENT_SESSION_TIMEOUT,0)); sslContext.getServerSessionContext().setSessionCacheSize(optionMap.get(Options.SSL_SERVER_SESSION_CACHE_SIZE,0)); sslContext.getServerSessionContext().setSessionTimeout(optionMap.get(Options.SSL_SERVER_SESSION_TIMEOUT,0)); return sslContext; }
Example 97
protected static SecurityOptions newTrustAnyoneOptions() throws KeyManagementException, NoSuchAlgorithmException { TrustManager[] trust=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return new X509Certificate[0]; } /** * @throws CertificateException */ public void checkClientTrusted( X509Certificate[] certs, String authType) throws CertificateException { } /** * @throws CertificateException */ public void checkServerTrusted( X509Certificate[] certs, String authType) throws CertificateException { } } }; SSLContext sslContext=SSLContext.getInstance("SSLv3"); sslContext.init(null,trust,null); return new SecurityOptions(sslContext); }
Example 98
From project xwiki-eclipse, under directory /plugins/org.xwiki.eclipse.core/src/main/java/org/xwiki/eclipse/core/.
Source file: CorePlugin.java

public void start(BundleContext context) throws Exception { super.start(context); plugin=this; TrustManager[] trustAllCertificates=new TrustManager[]{new X509TrustManager(){ public X509Certificate[] getAcceptedIssuers(){ return null; } public void checkClientTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } public void checkServerTrusted( X509Certificate[] arg0, String arg1) throws CertificateException { } } }; SSLContext sc=SSLContext.getInstance("SSL"); HostnameVerifier hv=new HostnameVerifier(){ public boolean verify( String arg0, SSLSession arg1){ return true; } } ; sc.init(null,trustAllCertificates,new java.security.SecureRandom()); HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); HttpsURLConnection.setDefaultHostnameVerifier(hv); }
Example 99
From project zirco-browser, under directory /src/org/emergent/android/weave/client/.
Source file: WeaveSSLSocketFactory.java

private static SSLContext createEasySSLContext() throws IOException { try { SSLContext context=SSLContext.getInstance("TLS"); context.init(null,new TrustManager[]{new WeaveX509TrustManager(null)},null); return context; } catch ( Exception e) { throw new IOException(e.getMessage()); } }