=htc move tests keys to src/test/resources (+ fix instructions)

This commit is contained in:
Johannes Rudolph 2015-08-13 08:23:16 +02:00
parent 560785eaaa
commit e460a58bc4
8 changed files with 8 additions and 4 deletions

View file

@ -17,9 +17,9 @@ openssl req -x509 -new -nodes -key rootCA.key -days 3560 -out rootCA.crt
# Create server key:
openssl genrsa -out device.key 2048
openssl genrsa -out server.key 2048
# Create server CSR:
# Create server CSR (you need to set the common name CN to "akka.example.org"):
openssl req -new -key server.key -out server.csr

View file

@ -16,11 +16,14 @@ import akka.http.scaladsl.HttpsContext
*/
object ExampleHttpContexts {
val exampleServerContext = {
// never put passwords into code!
val password = "abcdef".toCharArray
val ks = KeyStore.getInstance("PKCS12")
ks.load(resourceStream("keys/server.p12"), "abcdef".toCharArray)
ks.load(resourceStream("keys/server.p12"), password)
val keyManagerFactory = KeyManagerFactory.getInstance("SunX509")
keyManagerFactory.init(ks, "abcdef".toCharArray)
keyManagerFactory.init(ks, password)
val context = SSLContext.getInstance("TLS")
context.init(keyManagerFactory.getKeyManagers, null, new SecureRandom)
@ -30,6 +33,7 @@ object ExampleHttpContexts {
val exampleClientContext = {
val certStore = KeyStore.getInstance(KeyStore.getDefaultType)
certStore.load(null, null)
// only do this if you want to accept a custom root CA. Understand what you are doing!
certStore.setCertificateEntry("ca", loadX509Certificate("keys/rootCA.crt"))
val certManagerFactory = TrustManagerFactory.getInstance("SunX509")