All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.henricook.tls.x509.TrustStore.scala Maven / Gradle / Ivy

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"))
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy