summary refs log tree commit diff
path: root/crypto/src/pkcs/Pkcs12Store.cs
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/src/pkcs/Pkcs12Store.cs')
-rw-r--r--crypto/src/pkcs/Pkcs12Store.cs9
1 files changed, 3 insertions, 6 deletions
diff --git a/crypto/src/pkcs/Pkcs12Store.cs b/crypto/src/pkcs/Pkcs12Store.cs
index 2d7de67e6..832367e6b 100644
--- a/crypto/src/pkcs/Pkcs12Store.cs
+++ b/crypto/src/pkcs/Pkcs12Store.cs
@@ -304,7 +304,7 @@ namespace Org.BouncyCastle.Pkcs
 
                         foreach (Asn1Sequence subSeq in seq)
                         {
-                            SafeBag b = new SafeBag(subSeq);
+                            SafeBag b = SafeBag.GetInstance(subSeq);
 
                             if (b.BagID.Equals(PkcsObjectIdentifiers.CertBag))
                             {
@@ -334,7 +334,7 @@ namespace Org.BouncyCastle.Pkcs
 
             foreach (SafeBag b in certBags)
             {
-                CertBag certBag = new CertBag((Asn1Sequence)b.BagValue);
+                CertBag certBag = CertBag.GetInstance(b.BagValue);
                 byte[] octets = ((Asn1OctetString)certBag.CertValue).GetOctets();
                 X509Certificate cert = new X509CertificateParser().ReadCertificate(octets);
 
@@ -1030,10 +1030,7 @@ namespace Org.BouncyCastle.Pkcs
             //
             Pfx pfx = new Pfx(mainInfo, macData);
 
-            Asn1OutputStream derOut = Asn1OutputStream.Create(stream,
-                useDerEncoding ? Asn1Encodable.Der : Asn1Encodable.Ber);
-
-            derOut.WriteObject(pfx);
+            pfx.EncodeTo(stream, useDerEncoding ? Asn1Encodable.Der : Asn1Encodable.Ber);
         }
 
         internal static byte[] CalculatePbeMac(