Configure HTTPS for Spring Boot application on localhost with self-signed certificate

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi welcome to the video configure https on localhost for a springboard application with selfsite certificate i am namhaming from code java.net in details i will show you how to generate a ssl self-site certificate using the key tool in java and then how to enable https for springboot application and then install the self-size certificate on local computer you see i'm developing a web application on localhost and you see how it looks like in a browser here this is uh shop me e-commerce website and in the url you can see the url is localhost slash xiaomi and the collection is not secure this coding message displayed by the browser indicating that the connection to the server is not secure and this is a code in ide you see this web application is being developed based on java springboard and this is a spring application configuration file the embedded tomcat server is configured to be listening on the port number 80 here now let's open the new command prompt window and type key tool and if you set up the system environment variable for java properly you should see this key and certificate management tool syntax you see this key tool is available in the bin folder of zdk let me see the jdk directory on my computer you see i'm using open zdk version 15 and let me see the content of the bin directory you see the key tool here this is a k2 program a key and certificate management tool provided by java development jdk let me create a new directory using this command ssl and change the conductor to the new directory ssl and create a subjectory self-site okay and now type the command key to dash then keep to the right or keep up public and private keys to be used for ssl certificate and specify the alias or the unique name of the key pair is local underscore ssl you can assign any name for this alias and then the key algorithm is rsa which is a common cryptography algorithm and then specify the key size is 2048 bits and then specify the fly format of the keystore file start type is the common format b k cs kcs12 and then specify the keystore which is your file name i see if the name is local ssl dot b12 v12 is an extension of the pkcs12 file format and then specify the validation time with this flag validity and number of days is 365 days which is about one year and specifies the extension analysis extension sun equal dns and localhost for ssl certificate using on localhost and hit enter and then specify the keystore password and retype the password and specify some information first name and last name localhost development city san francisco state california us and type yes to confirm this information okay so we have successfully directed a key pair using rsa algorithm with keysight is 2048 bits it is the self-side certificate and you'll see the key star file selected here the local ssl dot p12 file here and open this directory in windows explorer start you see this is a key player store file for ssl this is to digital certificate okay and copy this p205 into the project here into the resources directory of the project here best you see so we have the certificate file here v125 and now restart the sorry and now we need to configure the springboard application configuration file here for enable enabling ssl enabling https and before that let's stop the application and update the port number for ssl here is 443 which is a port number for https and under server here specifies the property ssl enable equal to and specify the k key alias which local last ssl and key store key store and we use a prefix class part because we have the keystore file here copy the file name here and then specify the keystore file format this job type is bkcs12 and specify the key store password okay password and key store password is the same okay so this is a springboard configuration for enabling ssl and let's start the application you see without the exception key star password is incorrect and let me check one two three four five six and start again alias name does not identify key and g let me check a last name and last name is local underscore ssl and start again this time it should work okay you see the springboard application has started successfully and you see in the control view here tomcat started onboard 443 https with the context part is slashed xiaomi so far so good now let's switch to the browser and refresh the web application here sorry change the url to https double forward localhost slash xiaomi to access the web application via ssl and hit enter you see we got an error from the browser here the connection is not private and the error is short authority invalid it is because the self-site certificate is not charted by the browser so the next step is to install the self-size certificate on this computer now in the command prompt type this command to export a certificate from the keystore file so type k2 test export last key store and the keystore file name which is local ssl.b12 here and specify the earliest name is local underscore ssl and starts the related certificate file is local last third and enter the password okay done and it has inserted the certificate file stored in this file local dot crt you can see there's a certificate file here local dot crt and you can see in windows explorer here you see local sort and right click click install certificate okay click next and you you need to bless this certificate in the chat root chat root certification authorities here and click next and finish and when see this security warning click yes to install this certificate you see the import was successful and now we can close the browser open the browser again and access the web application again okay type https slash shop me and you see the backlog icon appears next to the url here click and you see the collection is secured and the certificate is valid click to see the details of the certificate here you see eco2 number here and you see it is valid from uh today to one year later yeah you see valid to september september the 1st 2022 to sum up the command for generating a key pair using the key tool in java is like this know that you must specify the extension ext send equal dns column localhost here so the self-sized certificate will be just browser browser and the command to export the certificate from the key stock file is analysis and configure the springboot application to enable https is like this you see and you must install the shelf size certificate to the trusted root certification authorities so far you have learned how to configure https or secure connection on localhost for a springboard application using self-site certificate i hope you found this video helpful please subscribe to my channel like comment and share this video thanks for watching
Info
Channel: Code Java
Views: 34,038
Rating: undefined out of 5
Keywords: Java, Spring Boot, SSL, spring boot ssl configuration, spring boot ssl certificate configuration, enable ssl in spring boot, how to enable ssl in spring boot application, enable https in spring boot, spring boot https, spring boot ssl localhost, spring boot https localhost
Id: eBEq0Kv7vsw
Channel Id: undefined
Length: 13min 30sec (810 seconds)
Published: Wed Sep 01 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.