How to add ssl certificate to tomcat on vps server

  1. We buy or acquire an ssl certificate from a domain name provider, for example. It also comes with a domain name for free. You can buy the cheapest domain for 85 rubles. in year. with postfix .xyz

  2. We receive a letter by mail with certificate and private key codes

  3. We are looking for lines in the letter —— BEGIN CERTIFICATE —— and —— END CERTIFICATE —— copy the contents, including these lines, create a certificate.crt file on the computer and paste the copied code inside

  4. We are looking for lines in the letter —— BEGIN RSA PRIVATE KEY —— and —— END RSA PRIVATE KEY —— copy the contents, including these lines, create a private.pem file on the computer and paste the copied code inside

  5. We got 2 files: certificate.crt – the certificate and private.pem – the private key. These files should be in the conf folder of the tomcat server. For example apache-tomcat-9.0.56 / conf

  6. In the conf folder of the tomcat server, we find the server.xml file and open it with the nano command on linux, or in a text editor.

  7. Find the line

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

8. Delete it and insert it instead

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
               maxThreads="150" SSLEnabled="true">
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/private.pem" 
               certificateFile="conf/certificate.crt"
                         type="RSA" />

9. Restart tomcat and you’re done

Similar Posts

Leave a Reply Cancel reply