Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting ssl keystore at runtime in Jetty

Is it possible to change keystore at runtime? Currently I am setting up SSL before I do a server.start() -

sslContextFactory.setTrustStore(ks);
sslContextFactory.setTrustStorePassword(TRUSTSTORE_PASS);
sslContextFactory.setKeyStorePassword(KEYSTORE_PASS); 
ServerConnector https = new ServerConnector(server, sslContextFactory);

server.start()

What I would like to do is create a certificate at runtime and use it. Basically I am creating a tool like Fiddler which creates certificates on the fly.

like image 675
gauravphoenix Avatar asked May 23 '13 05:05

gauravphoenix


People also ask

Is Truststore same as keyStore?

You can still use the same file as trustStore and keyStore in Java to avoid maintaining two separate files, but its a good idea to segregate public keys and private keys in two different files, it's more verbose and self-explanatory that which one holds CA certificates to trust the server and which contains the ...

Is JKS keystore or Truststore?

JKS keystore typeA Java Keystore (JKS) is a common keystore type that is used for Java environments because it is easier to set up. JKSs use files with a . jks extension that are stored in the zFS file system. The JKS is referenced by the keyStore element in the server.

How does SSL work with keyStore and Truststore?

Mobile Security Access Server supports an SSL keystore and SSL truststore. The SSL keystore holds the identity key for the server and the SSL truststore serves as the repository for trusted certificates. The SSL truststore is used for trusting or authenticating client certificates (for two-way SSL).


2 Answers

This has been fixed since Jetty 9.4.0, see https://github.com/eclipse/jetty.project/issues/918. You can now just override the Key/TrustStore etc. and call SslContextFactory.reload.

Note however there is a caveat with TLS session resumption: https://github.com/eclipse/jetty.project/issues/918#issuecomment-250791417. According to the comments, it shouldn't be an issue with common browsers, but who knows about IE, Mobile, non-browser clients, etc.

like image 184
Ben Romberg Avatar answered Sep 22 '22 15:09

Ben Romberg


After posting this question in Jetty mailing list, I got response that is it not really feasible

like image 24
gauravphoenix Avatar answered Sep 21 '22 15:09

gauravphoenix