Skip to content

Commit

Permalink
Merge remote-tracking branch 'torusrxxx/SSL' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneBab committed Jan 6, 2025
2 parents c556b9b + 2a23886 commit 3a315f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 0 additions & 5 deletions src/freenet/clients/http/ToadletContextImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,6 @@ static void sendReplyHeaders(
mvt.put("x-content-security-policy", contentSecurityPolicy);
mvt.put("x-webkit-csp", contentSecurityPolicy);
mvt.put("x-frame-options", allowFrames ? "SAMEORIGIN" : "DENY");
String HSTS = SSL.getHSTSHeader();
if(!HSTS.isEmpty() && !mvt.containsKey("strict-transport-security")) {
// SSL enabled, set strict-transport-security so that the user agent upgrade future requests to SSL.
mvt.put("strict-transport-security", HSTS);
}
StringBuilder buf = new StringBuilder(1024);
buf.append("HTTP/1.1 ");
buf.append(replyCode);
Expand Down
12 changes: 10 additions & 2 deletions src/freenet/crypt/SSL.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static boolean available() {
}

public static String getHSTSHeader() {
if(available() && HSTSMaxAge > 0)
if(enable && available() && HSTSMaxAge > 0)
return "max-age=" + HSTSMaxAge;
else
return "";
Expand Down Expand Up @@ -119,11 +119,16 @@ public void set(Boolean newValue) throws InvalidConfigValueException {
} catch(Exception e) {
enable = false;
e.printStackTrace(System.out);
Logger.error(this, "SSL could not be enabled", e);
throwConfigError("SSL could not be enabled", e);
}
else {
ssf = null;
keyStore = null;
try {
keystore.load(null, keyStorePass.toCharArray());
} catch (Exception e) {
// Just clear the key store
}
}
}
}
Expand All @@ -147,6 +152,7 @@ public void set(String newKeyStore) throws InvalidConfigValueException {
} catch(Exception e) {
keyStore = oldKeyStore;
e.printStackTrace(System.out);
Logger.error(this, "Keystore file could not be changed", e);
throwConfigError("Keystore file could not be changed", e);
}
}
Expand All @@ -171,6 +177,7 @@ public void set(String newKeyStorePass) throws InvalidConfigValueException {
} catch(Exception e) {
keyStorePass = oldKeyStorePass;
e.printStackTrace(System.out);
Logger.error(this, "Keystore password could not be changed", e);
throwConfigError("Keystore password could not be changed", e);
}
}
Expand Down Expand Up @@ -198,6 +205,7 @@ public void set(String newKeyPass) throws InvalidConfigValueException {
} catch(Exception e) {
keyPass = oldKeyPass;
e.printStackTrace(System.out);
Logger.error(this, "Private key password could not be changed", e);
throwConfigError("Private key password could not be changed", e);
}
}
Expand Down

0 comments on commit 3a315f8

Please sign in to comment.