Enterprise Java

How to configure an SSL Certificate with Play Framework for https

sslI spent hours tryĀ­ing to get this to work, and in the end, then probĀ­lem was that I did not genĀ­erĀ­ate the CSR (CerĀ­tifiĀ­cate Request) myself with the keytool.

I kept getĀ­ting this error when I tried accessĀ­ing Play with https:

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated

The probĀ­lem ended up being that the keyĀ­store I creĀ­ated and imported the SSL cerĀ­tifiĀ­cate into did not have the pubĀ­lic key that was used for the CSR (cerĀ­tifiĀ­cate request).

So here it the quick verĀ­sion of genĀ­erĀ­atĀ­ing an SSL CerĀ­tifiĀ­cate with godaddy​.com and installing it with Play FrameĀ­workĀ 2.1+.

  1. FolĀ­low these instrucĀ­tions from godaddy​.com to genĀ­erĀ­ate the CSR like this:

    First genĀ­erĀ­ate the key pair likeĀ this:

    keytool -keysize 2048 -genkey -alias tomcat -keyalg RSA -keystore tomcat.keystore

    Then genĀ­erĀ­ate theĀ CSR:

    keytool -certreq -alias tomcat -file csr.txt -keystore tomcat.keystore
  2. Use the CSR to apply for certificate
  3. Add the InterĀ­meĀ­diĀ­ate CerĀ­tifiĀ­cate BunĀ­dle and the CerĀ­tifiĀ­cate that were genĀ­erĀ­ated to your keyĀ­store.
    NOTE: make sure this is the same keyĀ­store that you genĀ­erĀ­ated the priĀ­vate key in, in stepĀ 1!

    keytool -import -alias intermed -keystore tomcat.keystore -trustcacerts -file gd_bundle.crt
    keytool -import -alias tomcat -keystore tomcat.keystore -trustcacerts -file mycert.crt

    (Replace mycert.crt with the file name and locaĀ­tion of the new GoDaddy certificate)

  4. Finally, folĀ­lowĀ­ing the instrucĀ­tions for conĀ­figĀ­urĀ­ing https with Play 2.1+ ( http://​www​.playframe​work​.com/​d​o​c​u​m​e​n​t​a​t​i​o​n​/​2​.​2​.​1​/​C​o​n​f​i​g​u​r​i​n​g​H​t​tps ) which had already worked great with the self genĀ­erĀ­ated key, I creĀ­ated a shell script for startĀ­ing Play with the corĀ­rect parameters:
    # script for starting play in production with SSL and the keystore
    target/start -Dhttps.port=443 -Dhttps.keyStore=/Users/bp/mypath/tomcat.keystore -Dhttps.keyStorePassword=itl80809

Note: you need to do a ā€œplay distā€ beforeĀ­hand, so that the curĀ­rent SoftĀ­ware is comĀ­piled into a disĀ­triĀ­bĀ­uĀ­tion in the tarĀ­get subdirectory.
 

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Back to top button