https işlevselliğini sınamak akka kod tabanı bazı testler vardır kullanıyor. ExampleHttpContexts'da tanımlanan önceden tanımlanmış http bağlamlarını kullanırlar.
Akka deposundan anahtarları kullanan küçük bir repo oluşturdum (umarım umursamayacaktır) ve kendinden imzalı bir sertifika here kullanarak minimum bir https sunucusu oluşturur. Bir repo yerine bir repo olarak işte bu yüzden sadece başlamak için klonlayabilirsiniz. http://doc.akka.io/docs/akka- [Sunucu Tarafı HTTPS desteği] (: belgelerinde sunucu boyutu HTTPS ile ilgili bir bölüm
package httpsserver
import java.security.{SecureRandom, KeyStore}
import javax.net.ssl.{KeyManagerFactory, SSLContext}
import akka.actor.ActorSystem
import akka.http.scaladsl.{HttpsContext, Http}
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.Route
import akka.stream.ActorMaterializer
object Server extends App {
val serverContext: HttpsContext = {
val password = "abcdef".toCharArray
val context = SSLContext.getInstance("TLS")
val ks = KeyStore.getInstance("PKCS12")
ks.load(getClass.getClassLoader.getResourceAsStream("keys/server.p12"), password)
val keyManagerFactory = KeyManagerFactory.getInstance("SunX509")
keyManagerFactory.init(ks, password)
context.init(keyManagerFactory.getKeyManagers, null, new SecureRandom)
// start up the web server
HttpsContext(context)
}
implicit val system = ActorSystem("server")
implicit val materializer = ActorMaterializer()
import system._
val route = Route(complete("ok"))
Http().bindAndHandle(route, interface = "0.0.0.0", port = 8081, httpsContext = Some(serverContext))
}
yok: İşte
scala kodudur akış-ve-http-deneysel/2.0.2/scala/http/alt düzey-sunucu tarafı-api.html # sunucu-tarafı-https-destek) – planetenkillerhttps proxy sunucusu olarak apache veya nginx kullanmanızı öneririm. Daha hızlı (nedeniyle C++ uygulama) ve sıklıkla yükseltilmiş (nedeniyle popülerlik) müthiş – mgosk