ASF Bugzilla – Attachment 30132 Details for
Bug 54759
SSLPeerUnverifiedException using HTTPS , property documented
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Test showing failure with HttpClient
WebClientDevWrapper.java (text/plain), 3.06 KB, created by
Philippe Mouawad
on 2013-04-01 20:34:02 UTC
(
hide
)
Description:
Test showing failure with HttpClient
Filename:
MIME Type:
Creator:
Philippe Mouawad
Created:
2013-04-01 20:34:02 UTC
Size:
3.06 KB
patch
obsolete
>package org.apache.jmeter; > >import java.io.IOException; >import java.security.cert.X509Certificate; > >import javax.net.ssl.SSLContext; >import javax.net.ssl.SSLException; >import javax.net.ssl.SSLSession; >import javax.net.ssl.SSLSocket; >import javax.net.ssl.TrustManager; >import javax.net.ssl.X509TrustManager; > >import org.apache.http.HttpResponse; >import org.apache.http.client.ClientProtocolException; >import org.apache.http.client.HttpClient; >import org.apache.http.client.methods.HttpGet; >import org.apache.http.conn.ClientConnectionManager; >import org.apache.http.conn.scheme.Scheme; >import org.apache.http.conn.scheme.SchemeRegistry; >import org.apache.http.conn.ssl.SSLSocketFactory; >import org.apache.http.conn.ssl.X509HostnameVerifier; >import org.apache.http.impl.client.DefaultHttpClient; > >public class WebClientDevWrapper { > public static HttpClient wrapClient(HttpClient base) { > try { > SSLContext ctx = SSLContext.getInstance("TLS"); > X509TrustManager tm = new X509TrustManager() { > @Override > public void checkClientTrusted(X509Certificate[] xcs, String string) { > } > @Override > public void checkServerTrusted(X509Certificate[] xcs, String string) { > } > @Override > public X509Certificate[] getAcceptedIssuers() { > return null; > } > }; > X509HostnameVerifier verifier = new X509HostnameVerifier() { > > @Override > public void verify(String string, SSLSocket ssls) throws IOException { > } > > @Override > public void verify(String string, X509Certificate xc) throws SSLException { > } > > @Override > public void verify(String string, String[] strings, String[] strings1) throws SSLException { > } > > @Override > public boolean verify(String string, SSLSession ssls) { > return true; > } > }; > ctx.init(null, new TrustManager[]{tm}, null); > SSLSocketFactory ssf = new SSLSocketFactory(ctx, verifier); > //ssf.setHostnameVerifier(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) { > ex.printStackTrace(); > return null; > } > } > > public static void main(String[] args) throws ClientProtocolException, IOException { > DefaultHttpClient client = new DefaultHttpClient(); > HttpClient httpClient = wrapClient(client); > HttpGet get = new HttpGet("https://clui.xstratacoal.com.au"); > //HttpGet get = new HttpGet("https://www.google.fr"); > HttpResponse httpResponse = > httpClient.execute(get); > System.out.println(httpResponse.getEntity().getContent()); > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 54759
:
30109
| 30132 |
30133