Process PKCS#12 Certificates and get data

Hello Guys,

Is there any similar method/s to System.Security.Cryptography.X509Certificates namespace from .Net ? or mode specific, System.Security.Cryptography.X509Certificates

I need to decrypt a certificate using the password I have and to get the details of if . On .Net I have the following code from a sample :

private static X509Certificate2 GetCertificate(byte[] certBytes, string certificatePW)
        {
            // The following code gets the cert from the keystore
            var certsInP12 = new X509Certificate2Collection();
            certsInP12.Import(certBytes, certificatePW, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.UserKeySet);

            X509Certificate2 certificateToFind = null;

            foreach (var c in certsInP12)
            {
                if (c.FriendlyName == "authentication")
                    certificateToFind = c;
                else if (c.Extensions.OfType<X509KeyUsageExtension>().FirstOrDefault().KeyUsages.HasFlag(X509KeyUsageFlags.NonRepudiation))
                    certificateToFind = c;
            }

            if (certificateToFind == null)
            {
                certificateToFind = new X509Certificate2(certBytes, certificatePW, X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable | X509KeyStorageFlags.MachineKeySet);
            }

            return certificateToFind;
        }

So I DO have to get the PrivateKey and to do some processing. I guess I could use terminal and some ssl commands but I was wondering if I can use something that XOJO has so that I don’t reinvent the wheel .

Thanks in advance

See MBS Plugins:

https://www.monkeybreadsoftware.net/pluginpart-openssl.shtml

We have classes for key and certificate. So

shared method ReadFromPkcs12(Data as String, Pass as String, byref PKey as PKeyMBS, byref Cert as X509MBS, byref certs() as X509MBS) as Boolean

Reads PKCS#12 file.
If needed I could add more methods.

[quote=404551:@Christian Schmitz]See MBS Plugins:

https://www.monkeybreadsoftware.net/pluginpart-openssl.shtml

We have classes for key and certificate. So

shared method ReadFromPkcs12(Data as String, Pass as String, byref PKey as PKeyMBS, byref Cert as X509MBS, byref certs() as X509MBS) as Boolean

Reads PKCS#12 file.
If needed I could add more methods.[/quote]
Thanks Christian, I saw a part of it, the rest of functionality I sent to you by mail, hope it will be more easy for you than for me.

Thanks again.