Support custom CA chain validation#1851
Conversation
|
How can I fix the build error?
|
| #endif | ||
|
|
||
| #if NET7_0_OR_GREATER | ||
| public string CertificationAuthoritiesFile { get; set; } |
There was a problem hiding this comment.
I'd recommend to make this API always visible but throw on the setter for <net7
There was a problem hiding this comment.
Other properties in this project are usually not available because they are excluded by the compiler. I would like to stick to this approach and avoid changing the strategy here.
| AllowRenegotiation = _tcpOptions.TlsOptions.AllowRenegotiation | ||
| }; | ||
| #if NET7_0_OR_GREATER | ||
| if (!string.IsNullOrEmpty(_tcpOptions.TlsOptions.CertificationAuthoritiesFile)) |
There was a problem hiding this comment.
another option: File.Exists (error when doesn't exist would be nice but possibly just letting it error later is fine as well, follow existing conventions)
| #endif | ||
|
|
||
| #if NET7_0_OR_GREATER | ||
| public MqttClientTlsOptionsBuilder WithCertificationAuthoritiesFile(string pemFile) |
There was a problem hiding this comment.
another option will be WithCaFile is shorter -not as descriptive as the other methods in this class - but is aligned with other mqtt tooling.
There was a problem hiding this comment.
The other methods and properties in this project usually take the "long" version or adopt the same name when it is simply mapped to a property in the .NET framework.
There was a problem hiding this comment.
this comment is outdated, the last commit changed the signature to: public MqttClientTlsOptionsBuilder WithTrustChain(X509Certificate2Collection chain)
To align with .NET api this could be .WithCustomTrustChain
|
I think it would be good to support handling of certificate authorities directly within the MQTTnet library. Some observations and questions:
|
|
thanks @logicaloud for you comments:
|
|
@logicaloud with this 0b5dff5 I've addressed your comments:
|
Well, keep in mind this is on top of MqttTlsOptions, so I guess the TrustChain concept will be easier to get. |
Summary
Most MQTT clients from Paho (python, Java, GO) and even mosquitto-clients, allow to specify a
CaFileto connect to TLS endpoints protected with certificates issued by a private CA.A good example is
test.mosquitto.org:8883that requires https://test.mosquitto.org/ssl/mosquitto.org.crt to validate the server connectionDetails
CertificationAuthoritiesFileoption to TlsOptionsWithCertificationAuthoritiesFile(string pemFile)to TlsOptionsBuilderOverseeds #1848