I have a root chain and certificate stored in a single .p7b file that I'd like to authenticate/bind to a Unity environment. I came across Unity's CertificateHandler class https://docs.unity3d.com/ScriptReference/Networking.CertificateHandler.html and Microsoft's X509Certificates. Using X509Certificate I'd like to validate my certificate like so:
byte[] content = File.ReadAllBytes("servercerts.p7b");
string contentString = Convert.ToBase64String(content);
X509Certificate2 certificate = new X509Certificate2(Convert.FromBase64String(contentString), string.Empty);
The Console output in Unity returns the message: CryptographicException: Input data cannot be coded as a valid certificate.
I have seen related issues where people have swapped out different parameters for X509Certificate2() though that type of solution has not been helpful in my case.