-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support CDI providers of key/trust stores in TLS registry #45937
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
I made a few comment and I added a question for @mkouba
extensions/tls-registry/deployment/src/main/java/io/quarkus/tls/CertificatesProcessor.java
Outdated
Show resolved
Hide resolved
extensions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/CertificateRecorder.java
Show resolved
Hide resolved
|
||
public interface KeyStoreProvider { | ||
|
||
KeyStoreAndKeyCertOptions getKeyStore(Vertx vertx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of javadoc would be nice
|
||
public interface TrustStoreProvider { | ||
|
||
TrustStoreAndTrustOptions getTrustStore(Vertx vertx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit of javadoc would be nice
...nsions/tls-registry/runtime/src/main/java/io/quarkus/tls/runtime/config/TlsBucketConfig.java
Show resolved
Hide resolved
I forgot to mention that this deserves a small section in the TLS registry documentation. |
This comment has been minimized.
This comment has been minimized.
🎊 PR Preview 83338cf has been successfully built and deployed to https://quarkus-pr-main-45937-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
@@ -188,4 +209,29 @@ public TlsConfigurationRegistry get() { | |||
public void register(String name, Supplier<TlsConfiguration> supplier) { | |||
register(name, supplier.get()); | |||
} | |||
|
|||
static void addNamedConfigForForProvidersIfNecessary(Class<?> type, Map<String, TlsBucketConfig> namedConfigs) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this method (that is called twice) can be completely replaced with. Also this way, you can drop changes in TlsBucketConfig
.
// alpn == true by default, but we need to set some property to let SR Config that we need a bucket with such name, maybe Roberto knows a better way
`new RunTimeConfigurationDefaultBuildItem("quarkus.tls.collected-identifier.alpn", "true")`
I didn't try it, I just think that's how this should work. Just tell config "I need these keys if user didn't configure them". Of course, there is even better way, I think you can use https://smallrye.io/smallrye-config/Main/config/mappings/, you collect all the identifiers during the build-time and then you create var namedConfigs = new HashMap<>(config.namedCertificateConfig());
as you already do and iterate over identifiers collected at the build-time and do config.namedCertificateConfig().get("identifier-abz")
and you don't care whether it is user config or defaults, because it will always return config for your identifiers.
But then maybe, @cescoffier don't want this in config 🤷 , I don't really know what is preferable for this extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean @WithDefaults
of the config mapping if it wasn't clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michalvavrik I think I understand what you mean, but I'm a bit unclear how to proceed. It would definitely be better to simply merge the @Identifier
values into the config at build time.
I think I would need a build step that can take the bean discovery and config state as input. Then I can find all the providers with annotations and collect the values. Then I need to put any missing names into the namedCertificateConfig
map with default values.
If you can give me a bit more guidance, I'll be happy to do it 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't really decide if this should be done in this extension. Nevertheless, I can give you guidance, this is just a metacode, you will need to figure details like everyone else. What I usually do is to simply look for usage of a class/method and "get inspired".
- in
initializeCertificate
injectCombinedIndexBuildItem
, getIdentifier
annotation instances from index, filter them by annotation target where it implementsKeyStoreProvider
orTrustStoreProvider
and collect identifier annotation instance values. I suppose you can stick toSet<String>
- pass it down to the
io.quarkus.tls.runtime.CertificateRecorder#validateCertificates
- add
@WithDefaults
topMap<String, TlsBucketConfig> namedCertificateConfig()
- create your final named configs like:
Set<String> identifiers; // method param
var namedConfigs = new HashMap<>(config.namedCertificateConfig());
for (String identifier : identifiers) {
if (!namedConfigs.containsKey(identifier)) {
namedConfigs.put(identifier, config.namedCertificateConfig().get(identifier));
}
}
Shout if you get stuck.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean @WithDefaults of the config mapping if it wasn't clear.
So if I add @WithDefaults
to TlsConfig::namedCertificateConfig
I should be able to get a default for any unconfigured key?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean @WithDefaults of the config mapping if it wasn't clear.
So if I add
@WithDefaults
toTlsConfig::namedCertificateConfig
I should be able to get a default for any unconfigured key?
yep; I supposed unasked question is what about unavailable beans, because this would create default config for these, no idea if that is an issue, I'd rather say no...
46074e3
to
1f63c0a
Compare
Per discussion #41024, this PR provides a mechanism for application code to supply keystores or truststores to the TLS registry.