-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Enhance SslInfo to support multiple certificate stores. #45355
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
base: 3.4.x
Are you sure you want to change the base?
Conversation
Signed-off-by: Joshua Chen <27291761@qq.com>
f0f5036
to
667d56a
Compare
What is the use-case behind displaying truststores (how would you use this information)? I feel if this is needed, it should be somehow separated from the keystore certs since they have fundamentally different purpose and mixing them could make things worse during troubleshooting. |
Build a dashboard similar to the one below (this is just an example and not the actual product we’ve chosen). https://grafana.com/grafana/dashboards/11707-ssl-monitoring-x509-cert/ What you mentioned makes sense, but here’s a concern: if someone is already using the endpoint to fetch data into a monitoring system, would changing the schema cause the API call to fail? I think this would be a breaking change. Are we really going to do this? If it’s confirmed, I’d be happy to contribute to this change. |
Right now, the json contains Maybe there's a usecase to display the certificates in a truststore, too: e.g. I have imported a certificate from my cluster in my truststore to be able to call them with But in that scenario wouldn't it make more sense to monitor and display the information from the server part (which holds the certificate and also the private key) instead of displaying truststore contents of the client? |
Certificate chain is another meaning. The reason why the certificate in my provided YAML does not display is that the previous logic lacked the logic to obtain the certificate from For truststore, your explanation is correct. I put multiple fixes in the same PR, which caused confusion. I have fixed multiple issues. |
I was talking about certificate chains in the context of a The JavaDoc for
So it only works on keys, and not, like in your example, on certificates. But why would you put a certificate in a keystore in the first place? Certficates should be put in a truststore. |
Get your point now. |
First we need to decide if we want to see certificates from a truststore in the info endpoint. What's your use case? Why do you want to monitor certificates in a truststore? You linked to two dashboards, but as far as i see they show the expiration of the certificate for which the client has the key and not the certificates in the truststore. |
As mentioned in the comment above, trustStore is used on the client side, such as enabling TLS connections with DB or MQ, or end-to-end TLS links based on HTTP protocol, etc. This is a must for some large companies that enable TLS, and even mandated by compliance laws in different countries. In my personal understanding, all certificates in use should be managed, regardless of whether they are stored in keyStore or trustStore. They are equally at risk of expiration, which can trigger production incidents. Regarding the dashboard, I cannot directly share the product we are using as it is a trade secret. But as I mentioned, in large companies, we need to manage all certificates uniformly to prevent expiration. Without it, we would lack a global monitoring view. |
So you essentially have a dashboard which monitors the server side (e.g. DB server) and shows the key expiration. That makes sense. And then you have another dashboard which monitors the client side (your app) which shows the expiration of the certificate of the DB server, which is in the truststore of the client? |
Most of the certificates are displayed on the same dashboard, but we will determine their owner based on extended information such as appName and notify them when the certificate needs to be renewed. For e2e TLS certificates, we need to notify all relevant app owners. Currently, we do not distinguish which store it is in, but it would be better if there were such a field to mark its store. In high-level management requirements, it does not matter which store it is in. We only need to know its owner and expiration date. Distinguishing the store helps frontline developers, but does not help high-level management requirements. BTW, we are using Spring Boot as one of our products, but the technology stack of large companies is much more complex. |
My two cents: Dashboards: if I understand correctly, the dashboards linked above (#45355 (comment)) do not need the truststore and the info endpoint should not be used to build such dashboards (for example aggregating the data is problematic). On the other hand, metrics are also provided so you can build such dashboards on that data. Breaking change: does not need to be I think but the next version is a major version. Truststore usage and claiming that it is a "must for some large companies": I feel you are using self-signed certificates. Having a custom truststore is definitely not a must regardless of company size (but you can have a cert that is issued by a trusted CA and the issuer cert is in the default truststore of Java).
Could you please mention a use-case where the server cert chain is not expired but the truststore chain is? Should not the two be the same (since the issuer cert is the same)? If the server cert is expired, it should not matter what is in the truststore or does it?
I'm not sure, see my previous point (regardless of company size).
I think this is the cause of the disconnect. It seems you are using the truststore for client-discovery. I feel this is a narrow use-case and I don't think the
|
you can try to understand the following two cases? Not all scenarios are supported by public CA certificates, and the default truststore of Java is not enough. I think you may have oversimplified the scenario. https://www.baeldung.com/spring-boot-kafka-ssl More scenarios are that we have dozens or hundreds of apps linked to DB, MQ, etc. via TLS. When the server's certificate expires and is renewed, we need to know how many client certificates need to be updated at the same time to prevent the server from being updated and the client forgetting to update the certificate, resulting in a mismatch and inability to connect to the server. We occasionally encounter situations where client certificates are forgotten to be updated because there are too many client services involved. We need a global dashboard to monitor all certificates, regardless of which store they belong to.
When we use -Djavax.net.ssl.trustStore=..., it cannot be monitored by the Spingboot ssl endpoint through SslInfoContributor. This is unmanageable, and I don't think this is what we want to see.
I think we enhance security by enabling TLS (and it is mandated by compliance laws in some countries). Trusting all certificates or only trusting the issuer is unacceptable, as it poses security risks. If this were really possible, we could just use HTTP. Why go through so much "trouble"? |
I can try. :) It seems the baeldung post (as every tutorial you can follow in your local dev environment) uses self-signed certs for convenience. This is so that you can try it out locally without getting (paying for) a cert from a trusted CA. This is only for local development purposes, maybe the post should have also called out that in prod self-signed certs are less fortunate.
Yes, this is what I referred above as "client-discovery". I still feel this is a narrow use-case. I think knowing the truststore(s) contents is a useful feature in some situations (self-signed certs) and maybe it should be added to
I think it can and it is manageable, please explain why you think otherwise.
I agree but this does not prevent people doing it. |
I try to answer two questions: one is that the default certificate in the Java JDK cannot meet the required scenarios, and the other is that the requirements I mentioned are not unique to my company. Let me continue to use AWS as a case. The default certificate in the Java JDK does not include the AWS RDS CA certificate. The JDK only contains the CA certificates mentioned on the page, so when RDS TLS is enabled, we need to additionally add the AWS RDS CA certificate to the truststore. However, AWS, as a sufficiently generic cloud service provider, does not have its certificate as a self-signed certificate for the company I serve. I believe this case is sufficiently marketable.
I think we are starting to turn the topic into "How does Spring Boot define a pattern to manage the certificates in use?". First, using javax.net.ssl.trustStore to load certificates instead of ssl.bundle cannot be monitored in the Spring Boot ssl endpoint. If I want to know what certificates are being used in the APP, I need to introduce more monitoring products, which complicates the implementation. I think the ssl endpoint method is a simple and convenient way. Regarding how to get more people to use ssl.bundle instead of javax.net.ssl.trustStore, we need to add more checkpoints around Spring Boot (I am not saying this is within the scope of Spingboot) to intercept the way that javax.net.ssl.trustStore is not allowed to load certificates so that the certificates can be monitored. If Spingboot is willing to do more, it may be possible to check whether javax.net.ssl.trustStore is used to load the certificate at startup. If so, give a prompt to suggest that developers use the Spring Boot pattern. |
Fixed the following issues: