Repository navigation
[backport camel-4.18.x] CAMEL-25645: camel-milo - let the OPC UA client validate the server certificate against a trust list - #28054
Conversation
…ertificate against a trust list milo-client and milo-browse kept the default certificate validator of the Eclipse Milo client configuration, which accepts any server certificate, and had no option to configure trust material. The client now validates the server certificate whenever the selected endpoint uses a security policy other than None, with the trust list in trustListDirectory or the validator in certificateValidator, and does not connect when neither is configured. trustAllCertificates accepts any server certificate. The trust list checks the application URI, the validity period and the revocation status, and a certificate issued by a CA needs a revocation list of that CA. The same validator checks the certificate that the user identity token is encrypted with. A missing trust configuration and a failed certificate or security check are logged at WARN, and the last connection failure is the cause of the "No connected" exception. Backport of apache#27824, adapted to camel-4.18.x: @UriParam has no security attribute on this branch, so trustAllCertificates is not marked insecure:ssl; the user name and password only come from the endpoint URI; SubscriptionManager uses synchronized blocks; the connection cache id does not contain the requested publishing interval. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
…value before the consumers start (apache#27999) Since CAMEL-25626 a consumer also delivers a null value with a Bad status, so a client that connected before the test wrote Foo received the initial Bad value of the item as well, and mock:trustAll got 2 messages. The two changes were merged on main 26 seconds apart and neither PR build ran with the other. The consumer routes now start after the value is written, as MonitorItemTest does since CAMEL-25626, so Foo is the first notification of each client. Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com> Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> (cherry picked from commit eb14b16)
davsclaus
left a comment
There was a problem hiding this comment.
Thanks @oscerd.
This port is adapted, so it was reviewed against 1109759 plus the test fix eb14b16 (#27999), which is folded in here. Each difference from main comes from code or API that camel-4.18.x lacks:
trustAllCertificateshas nosecurity = "insecure:ssl". The@UriParamon 4.18.x has nosecurityattribute, and the branch has noSecurityUtilsor security policy framework. That also explains why theSecurityUtilsowner map change is left out. So on 4.18.xtrustAllCertificates=trueis not reported by aprodprofile, but the default is stillfalseand the client still refuses to connect without trust settings.SubscriptionManagerpasses the validator to the onlyUsernameProviderthe branch has, the one built from the URI user info. Main's explicitusername/passwordprovider and itscreds.length == 2 ? creds[1] : ""empty-password handling come from CAMEL-23812 (58f5ca7), not from CAMEL-25645, so leaving them out is correct. The identity token check is complete for 4.18.x.lastConnectFailureis set in the branch'ssynchronizedhandleConnectionFailurerather than inside main's lock, so the behaviour is the same.toCacheId()andMiloClientConfigurationTestkeep the branch's cache id withoutrequestedPublishingInterval. The trust settings appended to it are the same as on main.- The catalog doc copies are not touched, because 4.18.x does not mirror component docs into the catalog.
ServerCertificateTrust, the docs and the three tests are the same as on main. Branch Milo is 1.1.1, still on the 1.x API. The generated files are consistent: both component JSON copies are identical, indexes are sequential, the three options show up at component and endpoint level, and the configurers, URI factories, component DSL and endpoint DSL are all regenerated. CI is green. The incremental build ran camel-milo (58 tests, 0 failures), including ServerCertificateValidationTest, ServerCertificateTrustTest (13 tests) and MiloClientConfigurationTest.
The upgrade guide note for this behaviour change (a client that used to connect to a Sign/SignAndEncrypt endpoint without trust settings now refuses to connect) is in #28055 on main, under "Upgrading from 4.18.5 to 4.18.6". That one can be merged once this is in.
LGTM.
Claude Code on behalf of Claus Ibsen
Backport of #27824, with the test follow-up #27999, onto
camel-4.18.x.Original PRs: #27824 - CAMEL-25645: camel-milo - let the OPC UA client validate the server certificate against a trust list, and #27999 - CAMEL-25645: camel-milo - ServerCertificateValidationTest writes the value before the consumers start
Target branch:
camel-4.18.xCAMEL-25645
What it does
As on main,
milo-clientandmilo-browsevalidate the certificate of the OPC UA server when the selected endpoint uses a security policy other thanNone:trustListDirectory: Milo's file based trust list. It checks the chain, the validity period, the revocation status and the application URI. A CA-issued certificate needs a CRL of its CA in the trust list.certificateValidator: a custom validator.trustAllCertificates.WARNthat says why.No connected.Adaptations for camel-4.18.x
The milo client code on this branch differs from main, so this is a hand port of the final state of #27824. It needs a review:
@UriParamhas nosecurityattribute on this branch, sotrustAllCertificatesis not markedinsecure:ssl. There is noSecurityUtilsregistry to regenerate, and no catalog doc copies.username/passwordoptions). The validator is passed to that singleUsernameProvider.SubscriptionManagerusessynchronizedblocks instead of a lock, andMiloClientConfiguration.clone()is the copy constructor, which now copies the new options.Tests
MonitorItemMultiConnectionsCertTest, already@Disabled), includingServerCertificateTrustTest,MiloClientConfigurationTestand the end-to-endServerCertificateValidationTest.Claude Code on behalf of Andrea Cosentino
🤖 Generated with Claude Code