Skip to content

Instantly share code, notes, and snippets.

@spockz
Created September 21, 2016 18:09
Show Gist options
  • Save spockz/5b58937a6e7435a6e490d0cf72e5f651 to your computer and use it in GitHub Desktop.
Save spockz/5b58937a6e7435a6e490d0cf72e5f651 to your computer and use it in GitHub Desktop.
object Foo {
def withTls(hostname: String, ciphers: Array[String]): Client = {
val socketAddressToEngine: SocketAddress => Engine = {
case sa: InetSocketAddress =>
val c = Ssl.client(hostname, sa.getPort)
c.self.setEnabledCipherSuites(ciphers)
c
case _ =>
val c = Ssl.client()
c.self.setEnabledCipherSuites(ciphers)
c
}
configured(Transport.TLSClientEngine(Some(socketAddressToEngine)))
.configured(Transporter.TLSHostname(Some(hostname)))
.configured(Transport.Tls(TlsConfig.ClientHostname(hostname)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment