From 9efecb455e75cedae0583b0bab16cf166e64bf7a Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 20 May 2022 10:51:47 +0430 Subject: enabled https and http2 --- Dockerfile | 1 + docker-compose.yaml | 2 +- src/main/resources/application.properties | 6 ++++++ tests.sh | 8 ++++---- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6122c76..f10d3ab 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM alpine:3.15 as certbuilder RUN apk add openssl WORKDIR /certs RUN openssl req -nodes -new -x509 -subj="/C=US/ST=Denial/L=springfield/O=Dis/CN=localhost" -keyout server.key -out server.cert +RUN openssl pkcs12 -export -out cert.p12 -inkey server.key -in server.cert -password pass:thequicklazybrownfox FROM gradle:7.3.3-jdk11-alpine AS builder WORKDIR /home/springapp diff --git a/docker-compose.yaml b/docker-compose.yaml index dd4939a..b1bb081 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -5,7 +5,7 @@ services: build: context: . ports: - - "9080:8080" + - "9080:8443" networks: - springnet cap_drop: diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 357f85a..e40aba9 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -7,3 +7,9 @@ spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect spring.jpa.properties.hibernate.format_sql=true server.error.include-message=always +server.http2.enabled=true +server.port=8443 +server.ssl.enabled=true +server.ssl.key-store=/certs/cert.p12 +server.ssl.key-store-type=PKCS12 +server.ssl.key-store-password=thequicklazybrownfox diff --git a/tests.sh b/tests.sh index 1187978..d23741f 100755 --- a/tests.sh +++ b/tests.sh @@ -1,6 +1,6 @@ #!/bin/sh -curl -X POST -H "Content-Type:application/json" -d '{"name":"doc1", "lastModified": 1652882691, "body":"Hello"}' "http://localhost:9080/api/v1/doc" -curl -X GET "http://localhost:9080/api/v1/doc/2" -curl -X DELETE "http://localhost:9080/api/v1/doc/1" -curl -X PUT -H "Content-Type:application/json" -d '{"id": 1, "body": "Die before I do"}' "http://localhost:9080/api/v1/doc/1" +curl -k -X POST -H "Content-Type:application/json" -d '{"name":"doc1", "lastModified": 1652882691, "body":"Hello"}' "https://localhost:9080/api/v1/doc" +curl -k -X GET "https://localhost:9080/api/v1/doc/2" +curl -k -X DELETE "https://localhost:9080/api/v1/doc/1" +curl -k -X PUT -H "Content-Type:application/json" -d '{"id": 1, "body": "Die before I do"}' "https://localhost:9080/api/v1/doc/1" -- cgit v1.2.3