2016-04-06 22:54:58 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2009-2016 Lightbend Inc. <http://www.lightbend.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package docs.http.scaladsl
|
|
|
|
|
|
|
|
|
|
import akka.actor.{ ActorLogging, ActorSystem }
|
|
|
|
|
import akka.http.scaladsl.Http
|
|
|
|
|
import akka.stream.ActorMaterializer
|
|
|
|
|
import akka.util.ByteString
|
|
|
|
|
import com.typesafe.sslconfig.akka.AkkaSSLConfig
|
2016-06-07 00:17:23 +02:00
|
|
|
import docs.CompileOnlySpec
|
2016-04-06 22:54:58 +02:00
|
|
|
import org.scalatest.{ Matchers, WordSpec }
|
|
|
|
|
|
2016-06-07 00:17:23 +02:00
|
|
|
class HttpsExamplesSpec extends WordSpec with Matchers with CompileOnlySpec {
|
2016-04-06 22:54:58 +02:00
|
|
|
|
2016-06-07 00:17:23 +02:00
|
|
|
"disable SNI for connection" in compileOnlySpec {
|
2016-04-06 22:54:58 +02:00
|
|
|
val unsafeHost = "example.com"
|
|
|
|
|
//#disable-sni-connection
|
|
|
|
|
implicit val system = ActorSystem()
|
|
|
|
|
implicit val mat = ActorMaterializer()
|
|
|
|
|
|
|
|
|
|
// WARNING: disabling SNI is a very bad idea, please don't unless you have a very good reason to.
|
|
|
|
|
val badSslConfig = AkkaSSLConfig().mapSettings(s => s.withLoose(s.loose.withDisableSNI(true)))
|
|
|
|
|
val badCtx = Http().createClientHttpsContext(badSslConfig)
|
|
|
|
|
Http().outgoingConnectionHttps(unsafeHost, connectionContext = badCtx)
|
|
|
|
|
//#disable-sni-connection
|
|
|
|
|
}
|
|
|
|
|
}
|