Skip to content
Snippets Groups Projects
Commit 84ef13d5 authored by Emmanuel Bruno's avatar Emmanuel Bruno
Browse files

fixes README.

parent 602d2ec7
No related branches found
No related tags found
No related merge requests found
.idea
README.md
docker-compose.yml
......@@ -2,20 +2,68 @@
## Steps to run this project
1. COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up --build -d
1. ```COMPOSE_DOCKER_CLI_BUILD=1 DOCKER_BUILDKIT=1 docker-compose up --build -d```
2. Visit
1. curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample
2. curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/hello
3. curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/main
4. curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons
5. curl -H "Content-Type: application/json" \
1. ```curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample```
2. ```curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/hello```
3. ```curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/main```
4. ```curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons```
5. ```
curl -H "Content-Type: application/json" \
-X POST \
-d '{"name":"Jeanne"}' \
http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons
6. curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403
7. curl -H "Accept: text/xml" http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons
## Import "real" certificate
6. ```
curl http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403```
7. ```curl -H "Accept: text/xml" http://localhost:8080/restApp-1.0-SNAPSHOT/resources/sample/persons```
## Use a "real" certificate
Récupérer le certificat du serveur
```
echo quit | openssl s_client \
-showcerts -servername localhost -connect localhost:8181 >! localhost.pem
```
Convertir en keystore java
```
keytool -noprompt -storepass storepass -import \
-trustcacerts -alias mycert -file localhost.pem -keystore mycert-pub.jks
```
Il est possible d'utiliser le certificat avec curl
```
curl --cacert localhost.pem \
https://localhost:8181/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403
```
Avec un reverse proxy :
```
echo quit | openssl s_client -showcerts \
-servername localhost -connect localhost:8888 >! nginx.pem
curl --cacert localhost.pem \
https://localhost:8181/restApp-1.0-SNAPSHOT/resources/sample/persons/843c8236-6c6b-450e-9aa3-211a9b897403
```
openssl x509 -outform der -in localhost.pem -out localhost.der
keytool -import -noprompt -trustcacerts -storepass storepass -alias localhost -keystore mycert-pub.jks -file localhost.der
......@@ -23,6 +23,13 @@ services:
H2_OPTIONS: '-ifNotExists -webAllowOthers -tcpAllowOthers -pgAllowOthers -ifNotExists'
volumes:
- h2data:/h2-data
reverse-proxy:
environment:
- NGINX_HOST=localhost
build: docker/nginx
volumes:
- ./docker/nginx/nginx.conf:/etc/nginx/nginx.conf
ports:
- "8888:443"
volumes:
h2data:
\ No newline at end of file
FROM nginx:1.20.2-alpine
RUN apk add openssl
RUN openssl req -x509 -nodes \
-days 365 \
-subj "/C=CA/ST=QC/O=Company, Inc./CN=mydomain.com" \
-addext "subjectAltName=DNS:mydomain.com" \
-newkey rsa:2048 \
-keyout /etc/ssl/private/nginx-selfsigned.key \
-out /etc/ssl/certs/nginx-selfsigned.crt;
\ No newline at end of file
events {
}
http {
server {
listen 80;
listen 443 ssl;
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
location / {
proxy_pass http://jakartaEE:8080;
}
}
}
\ No newline at end of file
......@@ -23,7 +23,7 @@ public class WsClient {
String pathtoCert = getClass().getClassLoader().getResource("mycert-pub.jks").toURI().getPath();
System.getProperties().put("javax.net.debug", "all");
System.getProperties().put("javax.net.debug", "ssl");
System.getProperties().put(SSLContextConfigurator.KEY_STORE_FILE, pathtoCert);
System.getProperties().put(SSLContextConfigurator.KEY_STORE_TYPE, "JKS");
System.getProperties().put(SSLContextConfigurator.TRUST_STORE_FILE, pathtoCert);
......@@ -42,7 +42,7 @@ public class WsClient {
public static void main(String[] args) {
try {
final WsClient clientEndPoint = new WsClient(new URI("ws://localhost:8080/wsApp-1.0-SNAPSHOT/hellows"));
final WsClient clientEndPoint = new WsClient(new URI("wss://localhost:8686/wsApp-1.0-SNAPSHOT/hellows"));
clientEndPoint.sendMessage("Hello 1 !");
Thread.sleep(5000);
clientEndPoint.sendMessage("Hello 2 !");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment