Internal.Cryptography.Pal.OpenSslPkcs12Reader.TryRead C# (CSharp) Method

TryRead() public static method

public static TryRead ( Microsoft.Win32.SafeHandles.SafeBioHandle fileBio, OpenSslPkcs12Reader &pkcs12Reader ) : bool
fileBio Microsoft.Win32.SafeHandles.SafeBioHandle
pkcs12Reader OpenSslPkcs12Reader
return bool
        public static bool TryRead(SafeBioHandle fileBio, out OpenSslPkcs12Reader pkcs12Reader)
        {
            SafePkcs12Handle p12 = Interop.Crypto.DecodePkcs12FromBio(fileBio);

            if (!p12.IsInvalid)
            {
                pkcs12Reader = new OpenSslPkcs12Reader(p12);
                return true;
            }

            p12.Dispose();
            pkcs12Reader = null;
            return false;
        }

Same methods

OpenSslPkcs12Reader::TryRead ( byte data, OpenSslPkcs12Reader &pkcs12Reader ) : bool

Usage Example

Beispiel #1
0
        public X509ContentType GetCertContentType(byte[] rawData)
        {
            {
                ICertificatePal certPal;

                if (OpenSslX509CertificateReader.TryReadX509Der(rawData, out certPal) ||
                    OpenSslX509CertificateReader.TryReadX509Pem(rawData, out certPal))
                {
                    certPal.Dispose();

                    return(X509ContentType.Cert);
                }
            }

            if (PkcsFormatReader.IsPkcs7(rawData))
            {
                return(X509ContentType.Pkcs7);
            }

            {
                OpenSslPkcs12Reader pfx;

                if (OpenSslPkcs12Reader.TryRead(rawData, out pfx))
                {
                    pfx.Dispose();
                    return(X509ContentType.Pkcs12);
                }
            }

            // Unsupported format.
            // Windows throws new CryptographicException(CRYPT_E_NO_MATCH)
            throw new CryptographicException();
        }
All Usage Examples Of Internal.Cryptography.Pal.OpenSslPkcs12Reader::TryRead