Thanks Julien. I have created my own TrustOptions, and although the TrustManagerFactory is instantiated, the TrustManager inside is never initialised or retrieved.
I have attached the code I have created below.
NetServerOptions netServerOptions = new NetServerOptions()
.setPort(port)
.setLogActivity(true)
.setClientAuth(ClientAuth.REQUIRED)
.setSsl(true)
.setTrustOptions(trustOptions)
.setPemKeyCertOptions(pemKeyCertOptions);
public class ReloadableTrustOptions implements TrustOptions {
private final Logger logger = LogManager.getLogger();
@Override
public TrustManagerFactory getTrustManagerFactory(Vertx vertx) throws Exception {
logger.debug("Creating custom Reloadable Trust Manager Factory.");
return new ReloadableTrustManagerFactory();
}
@Override
public TrustOptions clone() {
return new ReloadableTrustOptions();
}
}
public class ReloadableTrustManagerFactory extends TrustManagerFactory {
public ReloadableTrustManagerFactory() throws NoSuchAlgorithmException {
super(new TrustManagerFactorySpi() {
private Logger logger = LogManager.getLogger();
private TrustManager[] trustManagers;
@Override
protected void engineInit(KeyStore keyStore) throws KeyStoreException {
try {
TrustManager trustManager = new ReloadableX509TrustManager(null);
trustManagers = new TrustManager[]{trustManager};
} catch (AuthException e) {
logger.error("Failed to initialise Reloadable Trust Manager");
throw new KeyStoreException(e);
}
}
@Override
protected void engineInit(ManagerFactoryParameters managerFactoryParameters) throws InvalidAlgorithmParameterException {
try {
this.engineInit((KeyStore) null);
} catch (KeyStoreException e) {
throw new InvalidAlgorithmParameterException(e);
}
}
@Override
protected TrustManager[] engineGetTrustManagers() {
return trustManagers;
}
}, KeyPairGenerator.getInstance("RSA").getProvider(), KeyPairGenerator.getInstance("RSA").getAlgorithm());
}
}