Spring Boot Jetty server not works over https (SSL) - spring

I have a Spring Boot application which runs on a remote server. When I build it to work over HTTP everything works fine. But when I am trying to setup SSL the application not work. It doesn't throw errors or anything. But I can't access any page in the browser (I have tried https://www.example.com, https://www.example.com:8443, https://example.com etc).
I have built keystore.jks on remote server machine from certificate.crt (which I have bought for my domain on ssl).
I have the following application.properties:
server.port=8443
server.ssl.key-store=classpath:keystore.jks
server.ssl.key-store-password=PASSWORD
server.ssl.key-password=PASSWORD
I have tried different configurations but no results. The same story happens when I trying to run it on my local machine (I thought it is because of I am going to localhost when the certificate is for example.com but maybe it is the same problem).
Here is the server output:
INFO 11041 --- [ main] o.e.jetty.util.ssl.SslContextFactory : x509=X509#2a492f2a(jetty,h=[www.example.com, example.com],w=[]) for >SslContextFactory#3277e499(jar:file:/root/application.jar!/BOOT->INF/classes!/keystore.jks,null)
2018-05-13 13:21:56.175 INFO 11041 --- [ main] >o.e.jetty.server.AbstractConnector : Started >ServerConnector#7ac2e39b{SSL,[ssl, http/1.1]}{0.0.0.0:8443}
2018-05-13 13:21:56.176 INFO 11041 --- [ main] >.s.b.c.e.j.JettyEmbeddedServletContainer : Jetty started on port(s) 8443 (ssl, http/1.1)
2018-05-13 13:21:56.179 INFO 11041 --- [ main] >c.b.product.BootApplication : Started BootApplication in 4.786 seconds (JVM running for 5.151)
So everything seems to be fine but it doesn't work.

Problem solved. It was just wrong generated keystore.jks.

Related

Starting springboot application from IntelliJ community edition

How can we start a spring boot application in IntelliJ community edition. I don't see an embedded tomcat Included here. When I start the application from SpringBootApplication annotated class, getting the below messages only in the logger
2021-06-23 20:02:45.933 INFO 1086 --- [ main] r.e.r.RestapplicationApplication : Starting RestapplicationApplication using Java 11.0.11 on Antonys-MBP.home with PID 1086 (/Users/robin/Documents/work/workspace/restapplication/target/classes started by robin in /Users/robin/Documents/work/workspace/restapplication)
2021-06-23 20:02:45.938 INFO 1086 --- [ main] r.e.r.RestapplicationApplication : No active profile set, falling back to default profiles: default
2021-06-23 20:02:48.342 INFO 1086 --- [ main] r.e.r.RestapplicationApplication : Started RestapplicationApplication in 3.621 seconds (JVM running for 4.888)
Please help on how can I start the application in tomcat and test in Community Editon of IntelliJ
r.e.r.RestapplicationApplication : Started RestapplicationApplication
in 3.621 seconds (JVM running for 4.888)
The above line tells you that the embedded tomcat has already started at default port 8080 ( unless you have overridden port in configuration). You can try hitting the application on the port.

Docker, Mongodb,Spring Boot on Windows getting Connection refused error

I am using default docker image of MongoDB and trying to connect using simple spring Boot application on windows box.
mongoDB image is getting stared correctly
IP in mongoDB image
I have spring-boot-starter-data-mongodb in my class path. i am using all spring boot default and only using below property in application.properties.
spring.data.mongodb.host=192.168.99.100
On application startup getting Connection refused: connect error
Logs
019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Cluster created with settings {hosts=[192.168.99.100:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019-03-06 06:15:06.096 INFO 4664 --- [ main] org.mongodb.driver.cluster : Adding discovered server 192.168.99.100:27017 to client view of cluster
2019-03-06 06:15:06.356 WARN 4664 --- [ main] o.s.d.m.c.m.BasicMongoPersistentProperty : Customizing field name for id property not allowed! Custom name will not be considered!
2019-03-06 06:15:06.928 INFO 4664 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2019-03-06 06:15:07.164 INFO 4664 --- [68.99.100:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server 192.168.99.100:27017
What i am missing here ?
Not a MongoDB expert, but a moderate Docker user speaking: It looks like you are not publishing the port MongoDB runs by default: 27017. That's why your spring application could not get a connection and throws this exception:
Exception in monitor thread while connecting to server 192.168.99.100:27017
So you may try publishing the port by using -p 27017:27017when initiating mongo container.

Undertow http and https

I use embedded undertow server in my web project. It works well in Idea with listening port 80 and 443, following the log in idea.
2018-08-04 11:32:31.394 INFO 4933 --- [ main] o.s.b.w.e.u.UndertowServletWebServer : Undertow started on port(s) 443 (https) 80 (http) with context path ''
But when I run it on my ubuntu server or local command line:
java -jar xxxx.jar
Output log is
Undertow started on port(s) 443 (https) with context path ''
wihout listening port 80. I can only visit the site by inputing https://xxxx
handly.
I compared the log. The server log print the extra two lines
2018-08-04 11:38:37.950 WARN 14835 --- [ main] io.undertow.websockets.jsr : UT026009: XNIO worker was not set on WebSocketDeploymentInfo, the default worker will be used
2018-08-04 11:38:37.950 WARN 14835 --- [ main] io.undertow.websockets.jsr : UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used
I din't know what's wrong. Any answer is helpful. Thanks.

Boxfuse SSL Config with GoDaddy Certs

I have an Spring Boot App deployed at AWS with Boxfuse . I am trying to make the SSL work with "mydomain.com" .I got the certs from Godaddy . It works well with self-signed certificates. But when I tried it with GoDaddy certs , it says that Payload failed to come up within 300s . Do I need to configure anything at AWS or Godaddy .Right now I am having following configuration in my application.properties file .
server.port=443
server.ssl.enabled=true
server.ssl.key-store=classpath:example.jks
server.ssl.key-store-password=myS3cr3tPwd
server.ssl.trust-store=/cacerts/example.jks
server.ssl.trust-store-password=my0th3rPwd
Logs says this :
2017-01-19 09:22:38.315 INFO 895 --- [ main] s.b.c.e.t.TomcatEmbedded
ServletContainer : Tomcat started on port(s): 443 (https)
2017-01-19 09:22:38.338 INFO 895 --- [ main] com.unoiatech.o3.Applica
tion : Started Application in 50.814 seconds (JVM running for 51.171
)
The system is going down NOW!
Sent SIGTERM to all processes
2017-01-19 09:26:34.501 INFO 895 --- [ Thread-4] ationConfigEmbeddedWebAp
plicationContext : Closing org.springframework.boot.context.embedded.AnnotationC
onfigEmbeddedWebApplicationContext#73f0f3d4: startup date [Thu Jan 19 09:21:48 G
MT 2017]; root of context hierarchy
2017-01-19 09:26:34.530 INFO 895 --- [ Thread-4] o.s.j.e.a.AnnotationMBea
nExporter : Unregistering JMX-exposed beans on shutdown
2017-01-19 09:26:34.553 INFO 895 --- [ Thread-4] j.LocalContainerEntityMa
nagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'defaul
t'
Sent SIGKILL to all processes
Requesting system poweroff
[ 290.976653] reboot: Power down
I have no clue where to look for the issue . Any help would be appreciated .
Edit :
It is a t2.micro instance .
Command to run the app : boxfuse run myapp:1.x -env=test ,
Edit After adding port to command :
Also, It is working with port 8443.
Use PKCS12 format
I faced same issue solved using below command
openssl pkcs12 -export -in f8f628911xyzc.crt -inkey mydomain.com.key
-certfile gd_bundle-g2-g1.crt -out mydomain.p12

Spring boot with spring.data.mongodb.uri=mongodb://otherhost/test

I developed a Spring boot application with MongoDB. While the MongoDB in the localhost, it works fine, but when the MongoDB is in different the server, I changed the setting in application.properties as
spring.data.mongodb.uri=mongodb://192.168.7.31/gcp
spring.data.mongodb.username=xxx
spring.data.mongodb.password=xxxxxxx
the application faileds as it still looks for the mongoDB in localhost
2017-01-04 11:47:46.161 INFO 15610 --- [ main] org.mongodb.driver.cluster : Adding discovered server localhost:27017 to client view of cluster
2017-01-04 11:47:46.218 INFO 15610 --- [localhost:27017] org.mongodb.driver.cluster : Exception in monitor thread while connecting to server localhost:27017
com.mongodb.MongoSocketOpenException: Exception opening socket
at com.mongodb.connection.SocketStream.open(SocketStream.java:63) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:114) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.DefaultServerMonitor$ServerMonitorR
Anyone can help to tell me how to set the parameters?

Resources