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

[WFCORE-4223] IllegalArgumentException when add a server-ssl-sni-context with no host-context-map #3595

Merged
merged 1 commit into from
Jan 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1043,25 +1043,28 @@ protected ValueSupplier<SSLContext> getValueSupplier(ServiceBuilder<SSLContext>

ModelNode hostContextMap = HOST_CONTEXT_MAP.resolveModelAttribute(context, model);

Set<String> keys = hostContextMap.keys();
final Map<String, InjectedValue<SSLContext>> sslContextMap = new HashMap<>(keys.size());
for (String host : keys) {
String sslContextName = hostContextMap.require(host).asString();
final InjectedValue<SSLContext> injector = new InjectedValue<>();
serviceBuilder.addDependency(SSL_CONTEXT_RUNTIME_CAPABILITY.getCapabilityServiceName(sslContextName), SSLContext.class, injector);
sslContextMap.put(host, injector);
}

return () -> {
SNIContextMatcher.Builder builder = new SNIContextMatcher.Builder();
for(Map.Entry<String, InjectedValue<SSLContext>> e : sslContextMap.entrySet()) {
builder.addMatch(e.getKey(), e.getValue().getValue());
Set<String> keys;
if (hostContextMap.isDefined() && (keys = hostContextMap.keys()).size() > 0) {
final Map<String, InjectedValue<SSLContext>> sslContextMap = new HashMap<>(keys.size());
for (String host : keys) {
String sslContextName = hostContextMap.require(host).asString();
final InjectedValue<SSLContext> injector = new InjectedValue<>();
serviceBuilder.addDependency(SSL_CONTEXT_RUNTIME_CAPABILITY.getCapabilityServiceName(sslContextName), SSLContext.class, injector);
sslContextMap.put(host, injector);
}
return new SNISSLContext(builder
.setDefaultContext(defaultContext.getValue())
.build());

};
return () -> {
SNIContextMatcher.Builder builder = new SNIContextMatcher.Builder();
for(Map.Entry<String, InjectedValue<SSLContext>> e : sslContextMap.entrySet()) {
builder.addMatch(e.getKey(), e.getValue().getValue());
}
return new SNISSLContext(builder
.setDefaultContext(defaultContext.getValue())
.build());
};
} else {
return () -> defaultContext.getValue();
}
}
};

Expand Down