com.henricook.tls.x509.TrustStore.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cryptoutils_2.13 Show documentation
Show all versions of cryptoutils_2.13 Show documentation
Cryptoutils for Scala 2.12 and 2.13 - Forked from Karasiq
The newest version!
package com.henricook.tls.x509
import java.io.InputStream
import java.security.KeyStore
import com.henricook.tls.internal.ObjectLoader
import com.typesafe.config.ConfigFactory
/**
* Trust store loader utility
*/
object TrustStore extends ObjectLoader[KeyStore] {
override def fromInputStream(inputStream: InputStream): KeyStore = {
val trustStore = KeyStore.getInstance(KeyStore.getDefaultType)
trustStore.load(inputStream, null)
trustStore
}
/**
* Opens JKS trust store specified in configuration
* @return JKS trust store
*/
def default(): KeyStore = {
val config = ConfigFactory.load().getConfig("henricook.tls")
fromFile(config.getString("trust-store"))
}
}