Skip to content

Commit 7b56929

Browse files
JiriOndrusekgansheer
authored andcommitted
Generates certificates for cxf security tests (#7945)
--- Co-authored-by: gansheer <[email protected]>
1 parent e515128 commit 7b56929

File tree

14 files changed

+95
-13
lines changed

14 files changed

+95
-13
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
20+
set -e
21+
set -x
22+
23+
keySize=2048
24+
days=10000
25+
password="password"
26+
encryptionAlgo="aes-256-cbc"
27+
28+
workDir="target/openssl-work"
29+
destinationDir="src/main/resources"
30+
destinationTestDir="src/test/resources"
31+
32+
# see https://stackoverflow.com/a/54924640
33+
export MSYS_NO_PATHCONV=1
34+
35+
if [[ -n "${JAVA_HOME}" ]] ; then
36+
keytool="$JAVA_HOME/bin/keytool"
37+
elif ! [[ -x "$(command -v keytool)" ]] ; then
38+
echo 'Error: Either add keytool to PATH or set JAVA_HOME' >&2
39+
exit 1
40+
else
41+
keytool="keytool"
42+
fi
43+
44+
if ! [[ -x "$(command -v openssl)" ]] ; then
45+
echo 'Error: openssl is not installed.' >&2
46+
exit 1
47+
fi
48+
49+
mkdir -p "$workDir"
50+
mkdir -p "$destinationDir"
51+
52+
# Certificate authority
53+
openssl genrsa -out "$workDir/cxfca.key" $keySize
54+
openssl req -x509 -new -subj '/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=cxfca' -key "$workDir/cxfca.key" -nodes -out "$workDir/cxfca.pem" -days $days -extensions v3_req
55+
openssl req -new -subj '/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=cxfca' -x509 -key "$workDir/cxfca.key" -days $days -out "$workDir/cxfca.crt"
56+
57+
for actor in client service sts actas; do
58+
# Generate keys
59+
openssl genrsa -out "$workDir/$actor.key" $keySize
60+
61+
# Generate certificates
62+
openssl req -new -subj "/O=apache.org/OU=eng (NOT FOR PRODUCTION)/CN=$actor" -key "$workDir/$actor.key" -out "$workDir/$actor.csr"
63+
openssl x509 -req -in "$workDir/$actor.csr" -CA "$workDir/cxfca.pem" -CAkey "$workDir/cxfca.key" -CAcreateserial -days $days -out "$workDir/$actor.crt"
64+
65+
# Export keystores
66+
openssl pkcs12 -export -in "$workDir/$actor.crt" -inkey "$workDir/$actor.key" -certfile "$workDir/cxfca.crt" -name "my${actor}key" -out "$destinationDir/${actor}store.pkcs12" -passout pass:"$password" -keypbe "$encryptionAlgo" -certpbe "$encryptionAlgo"
67+
done
68+
69+
keytool -import -trustcacerts -alias mystskey -file "$workDir/sts.crt" -noprompt -keystore "$destinationDir/servicestore.pkcs12" -storepass "$password"
70+
71+
keytool -import -trustcacerts -alias actasclient -file "$workDir/actas.crt" -noprompt -keystore "$destinationDir/stsstore.pkcs12" -storepass "$password"
72+
keytool -import -trustcacerts -alias myclientkey -file "$workDir/client.crt" -noprompt -keystore "$destinationDir/stsstore.pkcs12" -storepass "$password"
73+
keytool -import -trustcacerts -alias myservicekey -file "$workDir/service.crt" -noprompt -keystore "$destinationDir/stsstore.pkcs12" -storepass "$password"
74+
75+
keytool -import -trustcacerts -alias myactaskey -file "$workDir/actas.crt" -noprompt -keystore "$destinationDir/clientstore.pkcs12" -storepass "$password"
76+
keytool -import -trustcacerts -alias myservicekey -file "$workDir/service.crt" -noprompt -keystore "$destinationDir/clientstore.pkcs12" -storepass "$password"
77+
keytool -import -trustcacerts -alias mystskey -file "$workDir/sts.crt" -noprompt -keystore "$destinationDir/clientstore.pkcs12" -storepass "$password"
78+
79+
mv "$destinationDir/clientstore.pkcs12" "$destinationTestDir/clientstore.pkcs12"
80+
rm "$destinationDir/actasstore.pkcs12"

integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/server/ServerCallbackHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
public class ServerCallbackHandler extends PasswordCallbackHandler {
2626

2727
public ServerCallbackHandler() {
28-
super(Map.of("myservicekey", "skpass"));
28+
super(Map.of("myservicekey", "password"));
2929
}
3030
}

integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/java/org/apache/camel/quarkus/component/cxf/soap/it/ws/trust/sts/StsCallbackHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class StsCallbackHandler extends PasswordCallbackHandler {
2626

2727
public StsCallbackHandler() {
2828
super(Map.of(
29-
"mystskey", "stskpass",
29+
"mystskey", "password",
3030
"alice", "clarinet"));
3131
}
3232
}
Binary file not shown.

integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/serviceKeystore.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@
3333
# under the License.
3434
#
3535
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
36-
org.apache.ws.security.crypto.merlin.keystore.type=jks
37-
org.apache.ws.security.crypto.merlin.keystore.password=sspass
36+
org.apache.ws.security.crypto.merlin.keystore.type=pkcs12
37+
org.apache.ws.security.crypto.merlin.keystore.password=password
3838
org.apache.ws.security.crypto.merlin.keystore.alias=myservicekey
39-
org.apache.ws.security.crypto.merlin.keystore.file=servicestore.jks
39+
org.apache.ws.security.crypto.merlin.keystore.file=servicestore.pkcs12
40+
4041

Binary file not shown.
Binary file not shown.

integration-test-groups/cxf-soap/cxf-soap-ws-trust/src/main/resources/stsKeystore.properties

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
# under the License.
3434
#
3535
org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
36-
org.apache.ws.security.crypto.merlin.keystore.type=jks
37-
org.apache.ws.security.crypto.merlin.keystore.password=stsspass
38-
org.apache.ws.security.crypto.merlin.keystore.file=stsstore.jks
36+
org.apache.ws.security.crypto.merlin.keystore.type=pkcs12
37+
org.apache.ws.security.crypto.merlin.keystore.password=password
38+
org.apache.ws.security.crypto.merlin.keystore.alias=mystskey
39+
org.apache.ws.security.crypto.merlin.keystore.file=stsstore.pkcs12
3940

Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)