Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL connections with required client auth throw bad_certificate errors. #55

Open
joshgontijo opened this issue Oct 12, 2017 · 0 comments

Comments

@joshgontijo
Copy link
Owner

From #120

I'm trying to make Unirest calls to internal servers that require client auth but I keep getting bad_certificate errors. I've checked everything about the client certs I'm using and they all check out. I've tried making openssl and curl calls with the same certs and they connect to the server via ssl just fine. I spent days troubleshooting the certificate to no avail. Then I finally decided to try making a simple URLConnection with the same certs and it worked fine. Is there a bug in Unirest that doesn't allow for SSL connections that require client auth?

// Set all ssl properties
System.setProperty("javax.net.ssl.keyStore", "/path/to/keystore");
System.setProperty("javax.net.ssl.keyStorePassword", "keystorePass");
System.setProperty("javax.net.ssl.trustStore", "/path/to/trustStore");
System.setProperty("javax.net.ssl.trustStorePassword", "truststorePass");

String uri = "https://server.net/REST/endpoint";
URL url = new URL(uri);

// This works fine
URLConnection con = url.openConnection();

// This does not work and throws bad_certificate errors
HttpResponse<JsonNode> jsonResp = Unirest.get(uri).asJson();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant