Exemple #1
0
        /// <summary>
        /// Factory method to create a X509Certificate from a PKCS7 encoded in DER
        /// </summary>
        /// <param name="bio"></param>
        /// <returns></returns>
        public static X509Certificate FromPKCS7_DER(BIO bio)
        {
            PKCS7     pkcs7 = PKCS7.FromDER(bio);
            X509Chain chain = pkcs7.Certificates;

            if (chain != null && chain.Count > 0)
            {
                return(new X509Certificate(chain[0].Handle, false));
            }
            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Factory method to create a X509Certificate from a PKCS7 encoded in PEM
        /// </summary>
        /// <param name="bio"></param>
        /// <returns></returns>
        public static X509Certificate FromPKCS7_PEM(BIO bio)
        {
            PKCS7     pkcs7 = PKCS7.FromPEM(bio);
            X509Chain chain = pkcs7.Certificates;

            if (chain != null && chain.Count > 0)
            {
                return(new X509Certificate(chain[0].Handle, false));
            }
            else
            {
                throw new OpenSslException();
            }
        }