System.Security.Cryptography.X509Certificates.X509Certificate2Collection.Export C# (CSharp) Method

Export() public method

public Export ( System contentType ) : byte[]
contentType System
return byte[]
        public byte[] Export(System.Security.Cryptography.X509Certificates.X509ContentType contentType)
        {
            throw null;
        }

Same methods

X509Certificate2Collection::Export ( System contentType, string password ) : byte[]
X509Certificate2Collection::Export ( X509ContentType contentType ) : byte[]
X509Certificate2Collection::Export ( X509ContentType contentType, string password ) : byte[]

Usage Example

示例#1
0
        private void CloneCertChain(Uri url, string destination)
        {
            IProxyClientFactory factory = proxyClientControl.Client;

            if (factory == null)
            {
                factory = new IpProxyClientFactory();
            }

            ProxyClient client = factory.Create(new Logger());
            collection = new X509Certificate2Collection();

            using (IDataAdapter adapter = client.Connect(new IpProxyToken(null, url.Host, url.Port, IpProxyToken.IpClientType.Tcp, false),
                new Logger(), new Nodes.MetaDictionary(), new Nodes.MetaDictionary(), new PropertyBag(), new Security.CredentialsManagerService()))
            {
                DataAdapterToStream stm = new DataAdapterToStream(adapter);

                using (SslStream ssl = new SslStream(stm, false, VerifyCallback))
                {
                    ssl.AuthenticateAsClient(url.Host);
                }
            }

            if (collection.Count > 0)
            {
                File.WriteAllBytes(Path.Combine(destination, String.Format("certchain_{0}.pfx", url.Host)), collection.Export(X509ContentType.Pfx));
                int count = 1;

                foreach (X509Certificate2 cert in collection)
                {
                    string path = Path.Combine(destination, String.Format("cert_{0}_{1}.cer", url.Host, count++));

                    File.WriteAllText(path, CertificateUtils.ExportToPEM(cert) +
                        CertificateUtils.ExportToPEM((RSA)cert.PrivateKey, null));
                }
            }
        }
All Usage Examples Of System.Security.Cryptography.X509Certificates.X509Certificate2Collection::Export