Skip to content

Allow empty keystore in SSLContextFactory. Fixes #1183 #1188

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ public SSLContext createSSLContext() throws GeneralSecurityException, IOExceptio
char[] keyPassword = properties.keyPassword();
KeyStore keyStore = createKeyStore();

try {
builder.loadKeyMaterial(keyStore, keyPassword);
}
catch (UnrecoverableKeyException e) {
if (keyPassword.length == 0) {
// Retry if empty password, see
// https://rt.openssl.org/Ticket/Display.html?id=1497&user=guest&pass=guest
builder.loadKeyMaterial(keyStore, new char[] { '\0' });
if (keyStore != null) {
try {
builder.loadKeyMaterial(keyStore, keyPassword);
}
else {
throw e;
catch (UnrecoverableKeyException e) {
if (keyPassword.length == 0) {
// Retry if empty password, see
// https://rt.openssl.org/Ticket/Display.html?id=1497&user=guest&pass=guest
builder.loadKeyMaterial(keyStore, new char[] { '\0' });
}
else {
throw e;
}
}
}

Expand All @@ -66,7 +68,7 @@ public SSLContext createSSLContext() throws GeneralSecurityException, IOExceptio

public KeyStore createKeyStore() throws GeneralSecurityException, IOException {
if (properties.getKeyStore() == null) {
throw new KeyStoreException("Keystore not specified.");
return null;
}
if (!properties.getKeyStore().exists()) {
throw new KeyStoreException("Keystore not exists: " + properties.getKeyStore());
Expand Down