-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
SslStreamCertificateContext forced validation, X509Chain platform differences #41552
Comments
Tagging subscribers to this area: @dotnet/ncl |
Currently, this factory will silently discard intermediate certificates if the X509Chain verification fails, depending on the platform:
I would like a flag or overload to avoid this behavior and have it just use the provided chain as is, including the root, without creating a dependency on the presence / absence of objects in the system certificate store. I believe that was also the wish of #35844 and earlier requests. Something like this: |
The root should never go out IMHO. If the peer does not have it (and trust it), the handshake will fail anyway. |
the condition was indeed wrong @dbeinder. fixed with #46904 for 5.0 Biggest technical problem with taking just the list and sending ASIS its fact that it is not doable on Windows AFAIK. The option to give the power to the caller was discussed. While I agree it may be useful for testing, it was rejected by quorum. Aside from testing corner cases, is there some particular problem you are trying to solve @dbeinder? There may be some more work in this area for 6.0 and I would like to understand the use case |
Thanks @wfurt, I must have misread the older discussions. I was mostly hoping for the option to lose the dependency on the Windows certificate store, with all its permissions and behind-the-scenes magic. While it is great to have the option to integrate X509 operations with the full framework that extends into smartcards / HSM hardware, etc - it would be really nice to be able have a fully self contained app, that just does TLS with the Root-CA and keys built into my app without going through the full cert store. The exceptions from the SChannel/SSPI backend are usually rather cryptic and generic and I've just wasted a lot of time debugging exceptions that came down to the certificate being stuck in the store but secured and the executing user not having the permissions - when all I'm trying to do is run a client app that has the CA embedded and the client private key in a config file. I understand SslStream is more geared towards the web with the full multi-RootCA infrastructure, but when I'm using it for securing a custom protocol with our own PKI, the cert store gets more in the way than it helps. Because we also deploy on Linux, where the certificate store is just emulated, I'd rather not use it at all. If we just used Windows, there could be an argument to take advantage of the deep integration into system users / permissions, but for our use case having a more platform-independent, self-contained TLS wrapper in .NET would be most useful. |
That is not possible on Windows. Schannel can only use certificates via store (and capi2) We wanted to take X509Certificate2Collection as custom trust for #45456 but it may not be possible because of Windows limitations. I think one way you can try to approach is to create and use custom store. It is still a store, but application it self can be responsible for maintaining the content. That is still not quite what you want but I'm not sure that is feasible on all platforms at the moment. That still leaves you with Schannel errors. I no way out of it at the moment. Perhaps you can do some chain and trust validation upfront e.g. use X509Chain before attempt of TLS handshake to see if the the chain can be constructed. That would at least show any problems with permissions or store content. |
I don't think we can implement it on Windows. In general there is no way how to pass specific certificates to SSPI and schannel to use them exactly. |
Description
I was looking forward to the resolution of #35844 and being able to explicitly set the certificate chain for a
SslStream
. In testing the current (5.0 preview8) implementation I found a few pain points:SslStreamCertificateContext
seems to do the opposite of what the bool impliesCreate
overload to create a context without chain validationX509Chain
Create
overload without verificationCreate
function, it works when creatingSslStreamCertificateContext
by invoking the private constructor using reflectionMy test code: in this gist
It shows the platform-dependent behavior of
X509Chain
and then starts a test server, so the advertised chain can be checked usingopenssl s_client -connect localhost:8077
Configuration
The text was updated successfully, but these errors were encountered: