Skip to content
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

4.x: TLS default config values #8206

Merged
merged 2 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
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
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 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.
Expand Down Expand Up @@ -50,7 +50,6 @@ public class ConfiguredTlsManager implements TlsManager {
// secure random cannot be stored in native image, it must
// be initialized at runtime
private static final LazyValue<SecureRandom> RANDOM = LazyValue.create(SecureRandom::new);

private final String name;
private final String type;

Expand Down Expand Up @@ -163,7 +162,11 @@ protected void initSslContext(TlsConfig tlsConfig,

SSLSessionContext serverSessionContext = sslContext.getServerSessionContext();
if (serverSessionContext != null) {
serverSessionContext.setSessionCacheSize(tlsConfig.sessionCacheSize());
if (tlsConfig.sessionCacheSize() != TlsConfig.DEFAULT_SESSION_CACHE_SIZE) {
// To allow javax.net.ssl.sessionCacheSize system property usage
// see javax.net.ssl.SSLSessionContext.getSessionCacheSize doc
serverSessionContext.setSessionCacheSize(tlsConfig.sessionCacheSize());
}
// seconds
serverSessionContext.setSessionTimeout((int) tlsConfig.sessionTimeout().toSeconds());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Oracle and/or its affiliates.
* Copyright (c) 2023, 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.
Expand Down Expand Up @@ -40,6 +40,14 @@ interface TlsConfigBlueprint extends Prototype.Factory<Tls> {
* The default protocol is set to {@value}.
*/
String DEFAULT_PROTOCOL = "TLS";
/**
* The default session cache size as defined for unset value in {@link javax.net.ssl.SSLSessionContext#getSessionCacheSize()}.
*/
int DEFAULT_SESSION_CACHE_SIZE = 20480;
/**
* The default session timeout as defined for unset value in {@link javax.net.ssl.SSLSessionContext#getSessionTimeout()}.
*/
String DEFAULT_SESSION_TIMEOUT = "PT24H";

@Prototype.FactoryMethod
static Optional<PrivateKey> createPrivateKey(Keys config) {
Expand Down Expand Up @@ -248,17 +256,17 @@ static List<X509Certificate> createTrust(Keys config) {
/**
* SSL session cache size.
*
* @return session cache size, defaults to 1024
* @return session cache size, defaults to {@value DEFAULT_SESSION_CACHE_SIZE}.
*/
@ConfiguredOption("1024")
@Option.DefaultInt(DEFAULT_SESSION_CACHE_SIZE)
int sessionCacheSize();

/**
* SSL session timeout.
*
* @return session timeout, defaults to 30 minutes
* @return session timeout, defaults to {@value DEFAULT_SESSION_TIMEOUT}.
*/
@ConfiguredOption("PT30M")
@Option.Default(DEFAULT_SESSION_TIMEOUT)
Duration sessionTimeout();

/**
Expand Down