From 65d98a78f955441e991c43fb81843f514f332d40 Mon Sep 17 00:00:00 2001 From: Maxim Nesen Date: Thu, 4 Jan 2024 13:42:52 +0100 Subject: [PATCH] webserver-signatures modifications Signed-off-by: Maxim Nesen --- .../security/webserver-signatures/README.md | 4 +++ .../automatic-store-generator.sh | 33 ++++++++++++++++++ .../SignatureExampleBuilderMain.java | 2 +- .../src/main/resources/keystore.p12 | Bin 2716 -> 2693 bytes .../src/main/resources/service1.yaml | 4 +-- 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100755 examples/security/webserver-signatures/automatic-store-generator.sh diff --git a/examples/security/webserver-signatures/README.md b/examples/security/webserver-signatures/README.md index 887e297d..bfeafcf7 100644 --- a/examples/security/webserver-signatures/README.md +++ b/examples/security/webserver-signatures/README.md @@ -14,6 +14,10 @@ There are two examples with exactly the same behavior 2. "internal" service protected by a combination of basic authentication (for user propagation) and http signature (for service authentication) +## Steps to generate keystore (optional) +1. run the scripts ``auomatic-store-generator.sh`` (openssl and keytool are required to be present on the PATH) +2. move generated ``keystore.p12`` into the ``main/resources`` folder + ## Build and run ```bash diff --git a/examples/security/webserver-signatures/automatic-store-generator.sh b/examples/security/webserver-signatures/automatic-store-generator.sh new file mode 100755 index 00000000..e82097c4 --- /dev/null +++ b/examples/security/webserver-signatures/automatic-store-generator.sh @@ -0,0 +1,33 @@ +#!/bin/bash +# +# Copyright (c) 2024 Oracle and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +echo 'Generate new key store...' +keytool -genkeypair -keyalg RSA -keysize 2048 -alias service_cert -dname "CN=security.j4c,O=Oracle,L=Prague,ST=Some-State,C=CZ" -validity 21650 -keystore keystore.p12 -storepass changeit -keypass changeit -deststoretype pkcs12 +echo 'Obtaining certificate...' +keytool -exportcert -keystore keystore.p12 -storepass changeit -alias service_cert -rfc -file service_cert.cer + +echo 'Adding single private key to the keystore...' +openssl pkcs12 -in keystore.p12 -nodes -out keystore-private.key -nocerts -passin pass:changeit +openssl pkcs12 -inkey keystore-private.key -export -out keystore.p12 -name myprivatekey -passin pass:changeit -passout pass:changeit -nocerts + +echo 'Adding self-signed certificate to the keystore...' +keytool -importcert -alias service_cert -file service_cert.cer -keystore keystore.p12 -storepass changeit -noprompt + +echo 'Cleaning key and cer files' +rm keystore-private.key service_cert.cer + + diff --git a/examples/security/webserver-signatures/src/main/java/io/helidon/security/examples/signatures/SignatureExampleBuilderMain.java b/examples/security/webserver-signatures/src/main/java/io/helidon/security/examples/signatures/SignatureExampleBuilderMain.java index ff0b1bbf..880f2ec7 100644 --- a/examples/security/webserver-signatures/src/main/java/io/helidon/security/examples/signatures/SignatureExampleBuilderMain.java +++ b/examples/security/webserver-signatures/src/main/java/io/helidon/security/examples/signatures/SignatureExampleBuilderMain.java @@ -219,7 +219,7 @@ private static OutboundTarget rsaTarget() { "src/main/resources/keystore.p12"))) .keystorePassphrase("changeit".toCharArray()) .keyAlias("myprivatekey") - .keyPassphrase("password") + .keyPassphrase("changeit") .build()) .build()) .build(); diff --git a/examples/security/webserver-signatures/src/main/resources/keystore.p12 b/examples/security/webserver-signatures/src/main/resources/keystore.p12 index d9bee733524ffbde9f8fb02a5dd44ce69cd72dad..17b7fbeb7823d3a18e4b6a394f71eb14d73a0971 100644 GIT binary patch literal 2693 zcmaKuc{CLM7Qko5j2V-eFjMv|g|Rh$jeRWHLZT;YmIm3^ktNK8u@y-eAzL9COCzGh zki9H3UX4hWNutQlmXs{dJMW!3@1OU_J@?$tz4!ay_j4|m0#5(|xv&(tA~%mhido7Q z0tf}(qrk<$6u8gjyaLAmX_X{dbEO4g}q!KvWN)GS=bu1_Xh% zz+(QCyjU?X?Al>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