本文整理汇总了Scala中javax.net.ssl.SSLContext类的典型用法代码示例。如果您正苦于以下问题:Scala SSLContext类的具体用法?Scala SSLContext怎么用?Scala SSLContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SSLContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: WebserverApp
//设置package包名称以及导入依赖的类
import java.security.KeyStore
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
import com.twitter.finagle.Http
import com.twitter.util.Await
import io.circe.generic.auto._
import io.finch._
import io.finch.circe._
object WebserverApp extends App {
def getSSLContext: SSLContext = {
// Create and initialize the SSLContext with key material
val passphrase = "sample".toCharArray()
val trustPassphrase = "sample".toCharArray()
// First initialize the key and trust material
val ksKeys = KeyStore.getInstance("JKS")
val keystoreResource = this.getClass.getClassLoader.getResourceAsStream("sample-keystore.jks")
ksKeys.load(keystoreResource, passphrase)
val ksTrust = KeyStore.getInstance("JKS")
val trustStoreResource = this.getClass.getClassLoader.getResourceAsStream("sample-keystore.jks")
ksTrust.load(trustStoreResource, trustPassphrase)
// KeyManagers decide which key material to us
val kmf = KeyManagerFactory.getInstance("SunX509")
kmf.init(ksKeys, passphrase)
// TrustManagers decide whether to allow connections
val tmf = TrustManagerFactory.getInstance("SunX509")
tmf.init(ksTrust)
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(kmf.getKeyManagers, tmf.getTrustManagers, null)
sslContext
}
def sample: Endpoint[String] =
get("sample") {
Ok("Was it a TLS connection?... probably not")
}
val routes = sample
val server = Http.server
.withTransport.tls(getSSLContext)
.serve(s":38082", routes.handle {
case e: Exception =>
InternalServerError(e)
}.toService)
println("Server running on :38082")
Await.result(server)
}
示例2: InsecureClient
//设置package包名称以及导入依赖的类
package uk.gov.hmrc.utils
import com.sun.jersey.api.client.{Client, ClientResponse}
import org.json4s.jackson.Serialization._
import javax.ws.rs.core.MediaType
import javax.net.ssl.{HostnameVerifier, SSLContext, SSLSession, X509TrustManager}
import com.sun.jersey.api.client.config.DefaultClientConfig
import com.sun.jersey.client.urlconnection.HTTPSProperties
import java.security.cert.X509Certificate
import com.sun.jersey.api.client.filter.GZIPContentEncodingFilter
class InsecureClient {
implicit val defaultFormats = json.JsonExtraction.formats
private val jsonContentType = MediaType.APPLICATION_JSON + ";charset=utf-8"
private val sslContext = SSLContext.getInstance("SSL")
sslContext.init(null, Array(new InsecureTrustManager), null)
private val config = new DefaultClientConfig()
config.getProperties.put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(
new HostnameVerifier() {
override def verify(s: String, sslSession: SSLSession): Boolean = true
},
sslContext
))
private val client = Client.create(config)
client.addFilter(new GZIPContentEncodingFilter(false))
def get[A](url: String)(implicit m: Manifest[A]): A = {
val response = client.resource(url).accept(jsonContentType).get[ClientResponse](classOf[ClientResponse])
val responseBody = response.getEntity(classOf[String])
println(s"TARGET = $url")
response.getStatus match {
case 200 => read[A](responseBody)
case _ => throw new RuntimeException(s"Unexpected response from $url, status code ${response.getStatus} : $responseBody")
}
}
def getRawResponse(url: String, contentType: String = jsonContentType)(implicit m: Manifest[String]): (Int, String) = {
val response = client.resource(url).accept(contentType).get[ClientResponse](classOf[ClientResponse])
val responseBody = response.getEntity(classOf[String])
val status = response.getStatus
(status, responseBody)
}
}
class InsecureTrustManager extends X509TrustManager {
def checkClientTrusted(p1: Array[X509Certificate], p2: String) {}
def checkServerTrusted(p1: Array[X509Certificate], p2: String) {}
def getAcceptedIssuers: Array[X509Certificate] = Array()
}
示例3: sslContext
//设置package包名称以及导入依赖的类
package org.packtpublishing.security
import java.security.{SecureRandom, KeyStore}
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
import spray.io.ServerSSLEngineProvider
import resource._
trait SslSupport {
val random = SecureRandom.getInstance("SHA1PRNG")
val keyStoreLocation = "/spray-book-catalog.jks"
val keyStorePassword = "passw0rd"
implicit def sslContext: SSLContext = {
val keyStore = KeyStore.getInstance("jks")
for (jks <- managed(getClass.getResourceAsStream(keyStoreLocation))) {
keyStore.load(jks, keyStorePassword.toCharArray)
}
val keyManagerFactory = KeyManagerFactory.getInstance("SunX509")
keyManagerFactory.init(keyStore, keyStorePassword.toCharArray)
val trustManagerFactory = TrustManagerFactory.getInstance("SunX509")
trustManagerFactory.init(keyStore)
val context = SSLContext.getInstance("TLS")
context.init(keyManagerFactory.getKeyManagers, trustManagerFactory.getTrustManagers, random)
context
}
implicit def sslEngineProvider: ServerSSLEngineProvider = {
ServerSSLEngineProvider { engine =>
engine.setEnabledProtocols(Array("TLSv1", "TLSv1.1", "TLSv1.2"))
engine
}
}
}
示例4: HttpClientProvider
//设置package包名称以及导入依赖的类
package org.zalando.react.nakadi.client.providers
import java.security.SecureRandom
import java.security.cert.X509Certificate
import javax.net.ssl.{SSLContext, TrustManager, X509TrustManager}
import akka.actor.ActorContext
import akka.http.scaladsl.Http.OutgoingConnection
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.http.scaladsl.settings.ClientConnectionSettings
import akka.http.scaladsl.{Http, HttpsConnectionContext}
import akka.stream.scaladsl.Flow
import scala.concurrent.Future
import scala.concurrent.duration._
class HttpClientProvider(actorContext: ActorContext,
server: String, port: Int,
isConnectionSSL: Boolean = false,
acceptAnyCertificate: Boolean = false,
connectionTimeout: FiniteDuration) {
val http = Http(actorContext.system)
private val settings = {
ClientConnectionSettings
.apply(actorContext.system)
.withConnectingTimeout(connectionTimeout)
.withIdleTimeout(Duration.Inf)
}
val connection: Flow[HttpRequest, HttpResponse, Future[OutgoingConnection]] = {
isConnectionSSL match {
case true =>
val sslContext = if (!acceptAnyCertificate) SSLContext.getDefault else {
val permissiveTrustManager: TrustManager = new X509TrustManager() {
override def checkClientTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
override def checkServerTrusted(chain: Array[X509Certificate], authType: String): Unit = {}
override def getAcceptedIssuers(): Array[X509Certificate] = Array.empty
}
val ctx = SSLContext.getInstance("TLS")
ctx.init(Array.empty, Array(permissiveTrustManager), new SecureRandom())
ctx
}
http.outgoingConnectionHttps(server, port, new HttpsConnectionContext(sslContext), settings = settings)
case false =>
http.outgoingConnection(server, port, settings = settings)
}
}
}
示例5: BlazeServerConfig
//设置package包名称以及导入依赖的类
package korolev.blazeServer
import java.net.InetAddress
import java.security.KeyStore
import javax.net.ssl.{KeyManagerFactory, SSLContext}
import org.http4s.blaze.util.BogusKeystore
import scala.concurrent.ExecutionContextExecutorService
sslContext: Option[SSLContext] = None,
bufferSize: Int = 8 * 1024,
doNotBlockCurrentThread: Boolean = false
)(
// Trampoline
implicit val executionContext: ExecutionContextExecutorService
)
object BlazeServerConfig {
def bogusSslContext: SSLContext = {
val ksStream = BogusKeystore.asInputStream()
assert(ksStream != null)
val ks = KeyStore.getInstance("JKS")
ks.load(ksStream, BogusKeystore.getKeyStorePassword)
val kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm())
kmf.init(ks, BogusKeystore.getCertificatePassword)
val context = SSLContext.getInstance("SSL")
context.init(kmf.getKeyManagers, null, null)
context
}
}
示例6: SauceLabsClient
//设置package包名称以及导入依赖的类
package tools
import java.nio.ByteBuffer
import java.util.Base64
import javax.net.ssl.SSLContext
import org.http4s.blaze.channel.nio2.ClientChannelFactory
import org.http4s.blaze.http.{HttpClient, HttpResponse}
import org.http4s.blaze.util.{Execution, GenericSSLContext}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
class SauceLabsClient(userName: String, accessKey: String, jobId: String) extends HttpClient {
import scala.concurrent.ExecutionContext.Implicits.global
override lazy val connectionManager = new ClientChannelFactory()
override protected val sslContext: SSLContext = GenericSSLContext.clientSSLContext()
def setName(name: String): Unit = {
putToJob(s"""{"name": "$name"}""")
}
def setPassed(passed: Boolean): Unit = {
putToJob(s"""{"passed": $passed}""")
}
def putToJob(data: String): Unit = {
val authorization = {
val s = s"$userName:$accessKey"
Base64.getEncoder.encodeToString(s.getBytes)
}
val headers = Seq(
"content-type" -> "application/json",
"authorization" -> s"Basic $authorization"
)
val response = PUT(
url = s"https://saucelabs.com/rest/v1/$userName/jobs/$jobId", headers,
body = ByteBuffer.wrap(data.getBytes),
5 seconds
)
Await.result(response, 10 seconds)
}
// Cause blaze client doesn't support anything else GET!
def PUT(url: String, headers: Seq[(String, String)], body: ByteBuffer,timeout: Duration): Future[HttpResponse] = {
val r = runReq("PUT", url, headers, body, timeout)
r.flatMap {
case r: HttpResponse => Future.successful(r)
case r => Future.failed(new Exception(s"Received invalid response type: ${r.getClass}"))
}(Execution.directec)
}
}
示例7: SSLContextTestUtil
//设置package包名称以及导入依赖的类
package mesosphere.marathon.integration.setup
import java.io.File
import java.net.URL
import javax.net.ssl.{ HttpsURLConnection, SSLContext }
import mesosphere.marathon.io.SSLContextUtil
object SSLContextTestUtil {
val keyStorePassword = "password"
lazy val selfSignedKeyStoreURL = Option(getClass.getResource("/test-keystore.jks").getFile).getOrElse(
throw new RuntimeException("Could not find resource /test-keystore.jks")
)
lazy val selfSignedKeyStorePath = new File(selfSignedKeyStoreURL).getAbsolutePath
lazy val selfSignedSSLContext = SSLContextUtil.createSSLContext(
Some(selfSignedKeyStorePath),
Some(keyStorePassword)
)
lazy val caTrustStoreURL = Option(getClass.getResource("/ca-truststore.jks")).getOrElse(
throw new RuntimeException("Could not find resource /ca-truststore.jks")
)
lazy val caTrustStorePath = caTrustStoreURL.getPath
lazy val caKeyStoreURL = Option(getClass.getResource("/ca-keystore.jks")).getOrElse(
throw new RuntimeException("Could not find resource /ca-keystore.jks")
)
lazy val caKeyStorePath = new File(caKeyStoreURL.getPath).getAbsolutePath
lazy val caSignedSSLContext: SSLContext = SSLContextUtil.createSSLContext(
Some(caKeyStorePath),
Some(keyStorePassword)
)
def sslConnection(url: URL, sslContext: SSLContext): HttpsURLConnection = {
val connection = url.openConnection().asInstanceOf[HttpsURLConnection]
connection.setSSLSocketFactory(sslContext.getSocketFactory)
connection
}
}
示例8: BlazeServerConfig
//设置package包名称以及导入依赖的类
package korolev.blazeServer
import java.net.InetAddress
import java.security.KeyStore
import javax.net.ssl.{KeyManagerFactory, SSLContext}
import org.http4s.blaze.util.BogusKeystore
import scala.concurrent.ExecutionContextExecutorService
case class BlazeServerConfig(
port: Int = 8080,
host: String = InetAddress.getLoopbackAddress.getHostAddress,
sslContext: Option[SSLContext] = None,
bufferSize: Int = 8 * 1024,
maxRequestBodySize: Int = 8 * 1024 * 1024,
maxRequestHeaderSize: Int = 10 * 1024,
doNotBlockCurrentThread: Boolean = false
)(
// Trampoline
implicit val executionContext: ExecutionContextExecutorService
)
object BlazeServerConfig {
def bogusSslContext: SSLContext = {
val ksStream = BogusKeystore.asInputStream()
assert(ksStream != null)
val ks = KeyStore.getInstance("JKS")
ks.load(ksStream, BogusKeystore.getKeyStorePassword)
val kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)
kmf.init(ks, BogusKeystore.getCertificatePassword)
val context = SSLContext.getInstance("SSL")
context.init(kmf.getKeyManagers, null, null)
context
}
}
示例9: SauceLabsClient
//设置package包名称以及导入依赖的类
package tools
import java.nio.ByteBuffer
import java.util.Base64
import javax.net.ssl.SSLContext
import org.http4s.blaze.channel.nio2.ClientChannelFactory
import org.http4s.blaze.http.{HttpClient, HttpResponse}
import org.http4s.blaze.util.{Execution, GenericSSLContext}
import scala.concurrent.{Await, Future}
import scala.concurrent.duration._
class SauceLabsClient(userName: String, accessKey: String, jobId: String) extends HttpClient {
import scala.concurrent.ExecutionContext.Implicits.global
override lazy val connectionManager = new ClientChannelFactory()
override protected val sslContext: SSLContext = GenericSSLContext.clientSSLContext()
def setName(name: String): Unit = {
putToJob(s"""{"name": "$name"}""")
}
def setPassed(passed: Boolean): Unit = {
putToJob(s"""{"passed": $passed}""")
}
def putToJob(data: String): Unit = {
val authorization = {
val s = s"$userName:$accessKey"
Base64.getEncoder.encodeToString(s.getBytes)
}
val headers = Seq(
"content-type" -> "application/json",
"authorization" -> s"Basic $authorization"
)
val response = PUT(
url = s"https://saucelabs.com/rest/v1/$userName/jobs/$jobId", headers,
body = ByteBuffer.wrap(data.getBytes),
5 seconds
)
Await.result(response, 10 seconds)
()
}
// Cause blaze client doesn't support anything else GET!
def PUT(url: String, headers: Seq[(String, String)], body: ByteBuffer,timeout: Duration): Future[HttpResponse] = {
val r = runReq("PUT", url, headers, body, timeout)
r.flatMap {
case r: HttpResponse => Future.successful(r)
case _ => Future.failed(new Exception(s"Received invalid response type: ${r.getClass}"))
}(Execution.directec)
}
}
示例10: createHTTPSContextWithPassword
//设置package包名称以及导入依赖的类
package org.nephtys.keepaseat
import java.io.InputStream
import java.security.{KeyStore, SecureRandom}
import javax.crypto.SecretKey
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
import akka.http.scaladsl.server.Route
import org.nephtys.cmac.MacSource
import org.nephtys.keepaseat.internal.{GetRetreiveRoute, LinkJWTRoute, PostChangesRoute, StaticRoute}
import org.nephtys.keepaseat.internal.configs.{AnalogInterfaceConfig, PasswordConfig, ServerConfig}
import org.nephtys.keepaseat.internal.validators.{SuperuserPostValidator, UserPostValidator}
import akka.actor.{ActorRef, ActorSystem}
import akka.http.scaladsl.{ConnectionContext, HttpsConnectionContext}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller
import akka.stream.ActorMaterializer
import org.nephtys.keepaseat.filter.XSSCleaner
def createHTTPSContextWithPassword(password: Array[Char], pkcs12file: InputStream, keystoreInstance: String =
"PKCS12",
keymanagerInstance: String = "SunX509", trustmanagerInstance: String = "SunX509")
(implicit system: ActorSystem, mat: ActorMaterializer):
HttpsConnectionContext = {
implicit val dispatcher = system.dispatcher
val ks: KeyStore = KeyStore.getInstance(keystoreInstance)
require(pkcs12file != null, "Keystore required!")
require(password != null, "Password required!")
ks.load(pkcs12file, password)
val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance(keymanagerInstance)
keyManagerFactory.init(ks, password)
val tmf: TrustManagerFactory = TrustManagerFactory.getInstance(trustmanagerInstance)
tmf.init(ks)
val sslContext: SSLContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagerFactory.getKeyManagers, tmf.getTrustManagers, new SecureRandom)
ConnectionContext.https(sslContext)
}
def createHTTPSContext(pkcs12file: InputStream, keystoreInstance: String = "PKCS12",
keymanagerInstance: String = "SunX509", trustmanagerInstance: String = "SunX509")
(implicit system: ActorSystem, mat: ActorMaterializer, serverConfig: ServerConfig):
HttpsConnectionContext = {
require(serverConfig.httpsPassword.isDefined,
"""createHTTPSContext, but https password was none. If the password " +
"is empty, use Some("") instead.""")
createHTTPSContextWithPassword(serverConfig.httpsPassword.get.toCharArray, pkcs12file,
keystoreInstance, keymanagerInstance,
trustmanagerInstance)
}
}
示例11: getSSLContext
//设置package包名称以及导入依赖的类
package rere.driver.connection
import java.io.ByteArrayInputStream
import java.security.KeyStore
import java.security.cert.{CertificateFactory, X509Certificate}
import javax.net.ssl.{SSLContext, TrustManagerFactory}
import rere.driver.TLSProtocolVersion
sealed trait SSLContextProvider {
def getSSLContext: SSLContext
}
class PreparedSSLContextProvider(context: SSLContext) extends SSLContextProvider {
override def getSSLContext: SSLContext = context
}
class FromCertificateFileProvider(bytes: Array[Byte], protocolVersion: TLSProtocolVersion) extends SSLContextProvider {
override def getSSLContext: SSLContext = {
val certificateFactory = CertificateFactory.getInstance("X.509")
val certificate = certificateFactory.generateCertificate(new ByteArrayInputStream(bytes)).asInstanceOf[X509Certificate]
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
val keyStore = KeyStore.getInstance(KeyStore.getDefaultType)
keyStore.load(null)
keyStore.setCertificateEntry("rootCa", certificate)
trustManagerFactory.init(keyStore)
val context = SSLContext.getInstance(protocolVersion.canonicalName)
context.init(null, trustManagerFactory.getTrustManagers, null)
context
}
}
示例12: sslFile
//设置package包名称以及导入依赖的类
package console
import java.security._
import java.io.{InputStream, FileInputStream, File}
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
import akka.http.scaladsl.{ConnectionContext, HttpsConnectionContext}
trait SslSupport {
val algorithm = "SunX509"
def sslFile: String
private def create(in: InputStream, keyPass: String, storePass: String) = {
val keyStore = KeyStore.getInstance("JKS")
keyStore.load(in, storePass.toCharArray)
val keyManagerFactory = KeyManagerFactory.getInstance(algorithm)
keyManagerFactory.init(keyStore, keyPass.toCharArray)
val tmf = TrustManagerFactory.getInstance(algorithm)
(tmf init keyStore)
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagerFactory.getKeyManagers, tmf.getTrustManagers, new SecureRandom)
(ConnectionContext https sslContext)
}
def https(keyPass: String, storePass: String): HttpsConnectionContext = {
val file = new File("./" + sslFile)
if(file.exists) create(new FileInputStream(file), keyPass, storePass)
else {
resource.managed(getClass.getResourceAsStream("/"+ sslFile))
.map { in => create(in, keyPass, storePass) }
.opt
.fold(throw new Exception("jks file hasn't been found"))(identity)
}
}
}
示例13: ClientSSLConfiguration
//设置package包名称以及导入依赖的类
package com.biosimilarity.evaluator.spray.client
import java.io.InputStream
import java.security.cert.{Certificate, CertificateFactory}
import java.security.{KeyStore, SecureRandom}
import javax.net.ssl.{SSLContext, SSLParameters, TrustManagerFactory}
import com.biosimilarity.evaluator.util._
import spray.io.{ClientSSLEngineProvider, SSLContextProvider}
object ClientSSLConfiguration {
private def loadX509Certificate(resourceName: String): Certificate = {
val certResource: InputStream = resourceStream(resourceName)
try {
CertificateFactory.getInstance("X.509").generateCertificate(certResource)
} finally {
certResource.close()
}
}
private def clientSSLContext: SSLContext = {
val keystore: KeyStore = KeyStore.getInstance(KeyStore.getDefaultType)
val trustManagerFactory: TrustManagerFactory = TrustManagerFactory.getInstance("SunX509")
val context: SSLContext = SSLContext.getInstance("TLS")
val params: SSLParameters = new SSLParameters
keystore.load(null, null)
keystore.setCertificateEntry("ca", loadX509Certificate("gloseval.pem"))
trustManagerFactory.init(keystore)
context.init(null, trustManagerFactory.getTrustManagers, new SecureRandom)
params.setEndpointIdentificationAlgorithm("https")
context
}
def clientSSLEngineProvider: ClientSSLEngineProvider = ClientSSLEngineProvider(identity)(SSLContextProvider.forContext(clientSSLContext))
}
示例14: SSLConfiguration
//设置package包名称以及导入依赖的类
package com.biosimilarity.evaluator.spray
import java.io.InputStream
import java.security.{KeyStore, SecureRandom}
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
import com.biosimilarity.evaluator.distribution.EvalConfigWrapper
import com.biosimilarity.evaluator.util._
import spray.io.{SSLContextProvider, ServerSSLEngineProvider}
object SSLConfiguration extends Serializable {
private def sslContext: SSLContext = {
val keystoreResource: InputStream = resourceStream("keystore.jks")
try {
val storepass: String = EvalConfigWrapper.readString("storepass")
val keypass: String = EvalConfigWrapper.readString("keypass")
val keyStore: KeyStore = KeyStore.getInstance("jks")
val keyManagerFactory: KeyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)
val trustManagerFactory: TrustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
val context: SSLContext = SSLContext.getInstance("TLS")
keyStore.load(keystoreResource, storepass.toCharArray)
keyManagerFactory.init(keyStore, keypass.toCharArray)
trustManagerFactory.init(keyStore)
context.init(keyManagerFactory.getKeyManagers, trustManagerFactory.getTrustManagers, new SecureRandom)
context
} finally {
keystoreResource.close()
}
}
def sslEngineProvider: ServerSSLEngineProvider = ServerSSLEngineProvider(identity)(SSLContextProvider.forContext(sslContext))
}
示例15: SSLUtil
//设置package包名称以及导入依赖的类
package org.hyperscala.util
import java.io.File
import java.nio.file.Files
import java.security.KeyStore
import javax.net.ssl.{KeyManagerFactory, SSLContext, TrustManagerFactory}
object SSLUtil {
def createSSLContext(keyStoreFile: File, password: String): SSLContext = {
val passwordChars = password.toCharArray
val keyStore = KeyStore.getInstance("JKS")
assert(keyStoreFile.exists(), s"No keystore file was found at the location: ${keyStoreFile.getAbsolutePath}")
val keyStoreInput = Files.newInputStream(keyStoreFile.toPath)
keyStore.load(keyStoreInput, passwordChars)
val keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)
keyManagerFactory.init(keyStore, passwordChars)
val keyManagers = keyManagerFactory.getKeyManagers
val trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
trustManagerFactory.init(keyStore)
val trustManagers = trustManagerFactory.getTrustManagers
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(keyManagers, trustManagers, null)
sslContext
}
}