-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
keytool
imports the only one certificate from the file
#18339
Comments
Some additional tests. sh-4.4$ ls /public-certs/
ca-bundle.crt ca-cert1.crt ca-cert2.crt |
@tolusha are those certs imported in the jdk truststore of the vscode-java container? |
@l0rd Here is entrypoint of the Dockerfile command to list certificates: keytool -list -keystore /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.272.b10-1.el8_2.x86_64/jre/lib/security/cacerts -storepass changeit |
Thanks @tolusha. So that's still a manual step as described in docs https://www.eclipse.org/che/docs/che-7/end-user-guide/using-maven-artifact-repositories/#using-self-signed-certificates-in-maven-projects_using-maven-artifact-repositories. |
Here is the script to import a bundle into jks: #!/bin/sh
function add_all_bundle_ca {
CA_FILE=$1
KEYSTORE_PATH=$2
KEYSTORE_PASSWORD=$3
if [ ! -f $CA_FILE ]; then
# CA bundle file doesn't exist, skip it
echo "Failed to import CA certificates from ${CA_FILE}. File doesn't exist"
return
fi
bundle_name=$(basename $CA_FILE)
cert_index=0
tmp_file=/tmp/cert.pem
is_cert=false
while IFS= read -r line; do
if [ "$line" == "-----BEGIN CERTIFICATE-----" ]; then
# Start copying a new certificate
is_cert=true
cert_index=$((cert_index+1))
# Reset destination file and add header line
echo $line > ${tmp_file}
elif [ "$line" == "-----END CERTIFICATE-----" ]; then
# End of the certificate is reached, add it to trust store
is_cert=false
echo $line >> ${tmp_file}
keytool -importcert -alias "${bundle_name}_${cert_index}" -keystore $KEYSTORE_PATH -file $tmp_file -storepass $KEYSTORE_PASSWORD -noprompt
elif [ "$is_cert" == true ]; then
# In the middle of a certificate, copy line to target file
echo $line >> ${tmp_file}
fi
done < "$CA_FILE"
# Clean up
rm -f $tmp_file
}
add_all_bundle_ca $@
|
Followup work downstream tracked in https://issues.redhat.com/projects/CRW/issues/CRW-1413 |
Describe the bug
keytoo -importcertl
is used to import certificate into java keystore. Accordingly to the doc [1] it can import onlyPKCS#7
formatted certificate otherwise it imports the first certificate from the given file.[1] https://docs.oracle.com/en/java/javase/14/docs/specs/man/keytool.html
Where is keytool used to import certificates?
Workaround
ca-certs
configmap (if it is not created) and put every single certificate in a dedicated key ending with.crt
(che-theia imports certificates ending with.crt
)spec.server.serverTrustStoreConfigMapName: ca-certs
Some useful commands to work with java keystore (che-server)
list certificates:
export certificates:
Che version
The text was updated successfully, but these errors were encountered: