Apache httpclient javax.net.ssl.SSLHandshakeException:
By : Hussein Jarrar
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The apache example only sets up a trust store. That will only use the CA cert. You need to also set up an "identity" for handling the client certificate. I realize you put them all in the same java keystore, and that is probably still okay (but normally they are in separate files). The example calls loadTrustMaterial(). You also need to call loadKeyMaterial().
|
HTTP transport error: javax.net.ssl.SSLHandshakeException
By : user3626200
Date : March 29 2020, 07:55 AM
this will help Finally got it working. I had to explicitly tell Glassfish about the cacerts to be used even with those certificates being available in the /jdk/jr, /jre and the glassfish domain config cacerts... code :
asadmin> create-jvm-options -Djavax.net.ssl.trustStore="/Program Files/Java/jre7/lib/security/cacerts"
|
Get request handshake_faliure:javax.net.ssl.SSLHandshakeException
By : Bobby
Date : March 29 2020, 07:55 AM
|
Windows.Web.Http.HttpClient and System.Net.Http.HttpClient receive different responses
By : Lucas Almeida
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further The problem was HttpClient didn't decompress gzip data as Nuf said in the comments. so I just wrote tiny code for gzip decompression. code :
public async Task<string> Request(Method method, string url, string postData)
{
var handler = new System.Net.Http.HttpClientHandler()
{
AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate
};
var http = new System.Net.Http.HttpClient(handler);
System.Net.Http.HttpResponseMessage response;
if (method == Method.POST)
{
var httpContent = new System.Net.Http.StringContent(postData, Encoding.UTF8, "application/x-www-form-urlencoded");
response = await http.PostAsync(new Uri(url), httpContent);
}
else
{
response = await http.GetAsync(new Uri(url));
}
return await response.Content.ReadAsStringAsync();
}
|
How to make a HTTP GET with custom certificate with Spring Boot / javax.net.ssl.SSLHandshakeException: Received fatal al
By : mit.es
Date : March 29 2020, 07:55 AM
this one helps. This is just an example, cobbled together from some old code from way back. I no longer have access to a SOAP service that requires mutual TLS and it is not tested in it's current form. That being said you should be able to use it as a starting point - depending on which libraries you're using. The important thing is to have your SOAP client provide the client certificate your provider gave you while making requests. code :
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import javax.net.ssl.KeyManagerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
import java.security.UnrecoverableKeyException;
import java.security.cert.CertificateException;
import java.util.Optional;
public class CrudeSoapClient {
private static void initKeyManager(YourSoapServicePort yourSoapServicePort) {
HTTPConduit httpConduit = (HTTPConduit) ClientProxy.getClient(yourSoapServicePort).getConduit();
TLSClientParameters tlsClientParameters = Optional.ofNullable(httpConduit.getTlsClientParameters()).orElseGet(TLSClientParameters::new);
tlsClientParameters.setKeyManagers(getKeyManagerFactory().getKeyManagers());
httpConduit.setTlsClientParameters(tlsClientParameters);
}
public static KeyManagerFactory getKeyManagerFactory() {
KeyManagerFactory keyManagerFactory = null;
try (InputStream inputStream = CrudeSoapClient.class.getClassLoader().getResourceAsStream("yourkeystore.pkcs12")) {
KeyStore ts = KeyStore.getInstance("PKCS12");
ts.load(inputStream, "yourpassword".toCharArray());
keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
keyManagerFactory.init(ts, "yourpassword".toCharArray());
} catch (Exception e) {
e.printStackTrace();
}
return keyManagerFactory;
}
}
YourSoapService yourSoapService = new YourSoapServicePort();
YourSoapServicePort yourSoapServicePort = yourSoapService.getYourSoapServicePort();
CrudeSoapClient.initKeyManager(yourSoapServicePort);
YourSoapServiceResponse response = yourSoapServicePort.getOperation(yourRequest);
//do whatever you need to do with the response
|