Skip to content

Instantly share code, notes, and snippets.

@wikier
Created February 16, 2014 08:49
Show Gist options
  • Save wikier/9031298 to your computer and use it in GitHub Desktop.
Save wikier/9031298 to your computer and use it in GitHub Desktop.
Load Redlink SSL certificate with RESTEasy Client 3.x
// load the certificate
InputStream fis = this.getClass().getResourceAsStream("/path/to/redlink-CA.crt");
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate cert = cf.generateCertificate(fis);
// load the keystore that includes self-signed cert as a "trusted" entry
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
keyStore.setCertificateEntry("redlink-CA", cert);
tmf.init(keyStore);
SSLContext ctx = SSLContext.getInstance("TLS");
ctx.init(null, tmf.getTrustManagers(), null);
// build the rest client
ResteasyClientBuilder clientBuilder = new ResteasyClientBuilder();
clientBuilder.sslContext(ctx);
@Ignaciofincatti
Copy link

Como estas Sergio, queremos consumir un webservice de link y nos topamos con este error
java.security.cert.CertificateException: No subject alternative names present.
o aveces no da error de atributos en el namespace
si tienes algun conocimiento y puedesorientarnos te agradeceria, saludos....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment