Play framework supported to serve HTTPS. We need to have a certificate
1. Create a self-signed SSL Certificate
Generate a private key:openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 1024 bit long modulus
.....................++++++
.................................++++++
unable to write 'random state'
e is 65537 (0x10001)
Enter pass phrase for server.key:
Verifying - Enter pass phrase for server.key:
Generate a CSR
openssl req -new -key server.key -out server.csr
Enter pass phrase for server.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]:VN
State or Province Name (full name) [Some-State]:HaNoi
Locality Name (eg, city) []:HaNoi
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Niteco Ltd
Organizational Unit Name (eg, section) []:Software technology
Common Name (e.g. server FQDN or YOUR name) []:niteco.se
Email Address []:nguyenanhkien2a at gmail dot com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:
Remove passphase from key
cp server.key server.key.org
openssl rsa -in server.key.org -out server.key
openssl rsa -in server.key.org -out server.key
Enter pass phrase for server.key.org:
writing RSA key
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
Signature ok
subject=/C=VN/ST=HaNoi/L=HaNoi/O=Niteco Ltd/OU=Software technology/CN=niteco.se/emailAddress=nguyenanhkien2a at gmail dot com
Getting Private key
2. Add the certificate in your configuration
Add the configuration below into file {APP}/conf/application.confhttps.port=9443
certificate.key.file=conf/server.key
certificate.file=conf/server.crt
certificate.password=Asdfg@123456
trustmanager.algorithm=JKS
Note: We must locate the server.crt and server.key in the application conf folder. Play framework cannot read from outsite folder
3. Restart your play application
No comments:
Post a Comment