diff --git a/app/org/elastic4play/ClientAuthSSLEngineProvider.scala b/app/org/elastic4play/ClientAuthSSLEngineProvider.scala index 44c023e..b5b1629 100644 --- a/app/org/elastic4play/ClientAuthSSLEngineProvider.scala +++ b/app/org/elastic4play/ClientAuthSSLEngineProvider.scala @@ -33,20 +33,23 @@ class ClientAuthSSLEngineProvider(serverConfig: ServerConfig, appProvider: Appli } def readTrustManagers(): Array[TrustManager] = { - val trustStorePath = Paths.get(config.get[String]("play.server.https.trustStore.path")) - val keyStoreType = config.getOptional[String]("play.server.https.keyStore.type").getOrElse(KeyStore.getDefaultType) - val trustStorePassword = config.getOptional[String]("play.server.https.trustStore.password").getOrElse("").toCharArray - val trustInputStream = Files.newInputStream(trustStorePath) - try { - val keyStore = KeyStore.getInstance(keyStoreType) - keyStore.load(trustInputStream, trustStorePassword) - val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm) - tmf.init(keyStore) - tmf.getTrustManagers - } - finally { - trustInputStream.close() - } + config.getOptional[String]("play.server.https.trustStore.path") + .map { trustStorePath ⇒ + val keyStoreType = config.getOptional[String]("play.server.https.keyStore.type").getOrElse(KeyStore.getDefaultType) + val trustStorePassword = config.getOptional[String]("play.server.https.trustStore.password").getOrElse("").toCharArray + val trustInputStream = Files.newInputStream(Paths.get(trustStorePath)) + try { + val keyStore = KeyStore.getInstance(keyStoreType) + keyStore.load(trustInputStream, trustStorePassword) + val tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm) + tmf.init(keyStore) + tmf.getTrustManagers + } + finally { + trustInputStream.close() + } + } + .getOrElse(Array.empty) } def createSSLContext(applicationProvider: ApplicationProvider): SSLContext = {