I'm struggling with the apparent lack of flexibility in SslStream AuthenticateAsServer. I have a self-signed rootCA, an intermediate CA, and an end-entity (host) certificate. I am only doing server authentication. The client has the rootCA cert baked in, and I am trying to come up with some way to send the full chain from the server to the client, so that the client can validate the server, and I can additionally compare the thumbprints of the trust anchor rootCA with that included in the client.
Ideally I would like to avoid using the cert store and send the certificates explicitly. If anyone knows how to do this, it is the immediate best solution to my problem.
But it seems that SslStream AuthenticateAsServer will not in any documented way let you explicitly specify a chain to send. You must just send the bottom cert, and let it dig the rest out of the cert store. This is less than ideal but it seems like the only option so I am trying it that way. The problem now, is that (with the self signed CA in the Trusted Root Certification Authorities, and the intermediate in the Intermediate Root Certification Authorities on the server) only the host cert and the intermedate cert are being "automagically" sent to the client. I am only getting those two certs on the client, not the rootCA cert. Why?
Is there a way to AuthenticateAsServer with an cert chain?
If not, is it a thing that it will cut the root cert off the top of the chain before sending?
If there are no answers to the above, is there at least a way to shunt the (auto)magic that digs the rest of the chain out of the store, where I can look at the result, rather than having to go through AuthenticateAsServer, to the client CertValidationCallback? Atleast this way I would be debugging a single black box, rather than a string of several black boxes.