Akka HTTP
で(とりあえず)HTTPS通信をするための備忘録。
Akka HTTPでHTTPS通信をするには?
公式ドキュメントに書いてあるとおりにする。
言われたとおりにするためにPKCS12形式のファイルを作成する。
PKCS12ファイルの作成
秘密鍵の作成
# AES128で2048bitの秘密鍵
# このファイルは公開してはいけない
> openssl genrsa -aes128 2048 > sample.key
Generating RSA private key, 2048 bit long modulus
....+++
.........................+++
e is 65537 (0x010001)
Enter pass phrase:
Verifying - Enter pass phrase:
CSR(証明書署名要求)の作成
色々聞かれるけど、任意入力なので無視することも可能。
> openssl req -new -key sample.key > sample.csr
Enter pass phrase for sample.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
署名
# 有効期限は365000日(1000年)
> openssl x509 -in sample.csr -days 365000 -req -signkey sample.key > sample.crt
Signature ok
subject=C = AU, ST = Some-State, O = Internet Widgits Pty Ltd
Getting Private key
Enter pass phrase for sample.key:
PKCS12形式に変換する
> openssl pkcs12 -export -inkey sample.key -in sample.crt -out sample.p12
Enter pass phrase for sample.key:
Enter Export Password:
Verifying - Enter Export Password:
あとは
resources
などのパスが通っている場所にPKCS12ファイルを置けばAkka HTTP
でHTTPS通信ができるようになる。