Small topic for configuration ssl in local tomcat server. Ch-039 group used tomcat server v.8... Java (annotation) spring configuration.
1 step. Enable ssl in spring security.
@Override
protected void configure(HttpSecurity http) throws Exception {
.....
.and().requiresChannel().anyRequest().requiresSecure();
}
2 step. Create and connect to tomcat security certificate. Fisrt, open the terminal on your computer and type: Windows:
cd %JAVA_HOME%/bin
Linux or Mac OS:
cd $JAVA_HOME/bin
The $JAVA_HOME on Mac is located on “/System/Library/Frameworks/JavaVM.framework/Versions/{your java version}/Home/”
You will change the current directory to the directory Java is installed on your computer. Inside the Java Home directory, cd to the bin folder. Inside the bin folder there is a file named keytool. This guy is responsible for generating the keystore file for us.
Next, type on the terminal:
keytool -genkey -alias tomcat -keyalg RSA
When you type the command above, it will ask you some questions. First, it will ask you to create a password (My password is “password“):
loiane:bin loiane$ keytool -genkey -alias tomcat -keyalg RSA
Enter keystore password: password
Re-enter new password: password
What is your first and last name?
[Unknown]: Loiane Groner
What is the name of your organizational unit?
[Unknown]: home
What is the name of your organization?
[Unknown]: home
What is the name of your City or Locality?
[Unknown]: Sao Paulo
What is the name of your State or Province?
[Unknown]: SP
What is the two-letter country code for this unit?
[Unknown]: BR
Is CN=Loiane Groner, OU=home, O=home, L=Sao Paulo, ST=SP, C=BR correct?
[no]: yes
Enter key password for
(RETURN if same as keystore password): password
Re-enter new password: password
It will create a .keystore file on your user home directory. On Windows, it will be on: C:Documents and Settings[username]; on Mac it will be on /Users/[username] and on Linux will be on /home/[username].
3 step. Configuring Tomcat for using the keystore file – SSL config Open your Tomcat installation directory and open the conf folder. Inside this folder, you will find the server.xml file. Open it.
Find the following declaration:
<!--
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />
-->
Uncomment it and modify it to look like the following:
Connector SSLEnabled="true" acceptCount="100" clientAuth="false"
disableUploadTimeout="true" enableLookups="false" maxThreads="25"
port="8443" keystoreFile="/Users/loiane/.keystore" keystorePass="password"
protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https"
secure="true" sslProtocol="TLS" />
4 step. Let’s test it! Start tomcat service and try to access https://localhost:8443. You will see Tomcat’s local home page.
Сonfiguration information was taken from the site https://dzone.com/
Copyright(c) 2016 Dream-Team CH-039
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&key=AIzaSyDGjdYjvXcz-2fFmj0JFyt-JPZ0cZBBhmE"></script>Google asks for developer key for using it's POI (key=AIzaSyDGjdYjvXcz-2fFmj0JFyt-JPZ0cZBBhmE). Enabled API: Google Maps Geocoding API Google Maps JavaScript API Google Places API Web Service You have to register new key and replace it in layout.html
Default folder is %CATALINA_HOME%/hospitalseeker/images/*** where *** folder for different types of images (hospital, avatar, etc) These can be changed at uploadr.properties at resources folder.