+#if MONO_FEATURE_APPLETLS || MONO_FEATURE_APPLE_X509
using System;
using System.Runtime.InteropServices;
using MX = Mono.Security.X509;
{
static partial class X509Helper
{
- public static X509CertificateImpl InitFromHandle (IntPtr handle)
+ public static X509CertificateImpl InitFromHandleApple (IntPtr handle)
{
return new X509CertificateImplApple (handle, false);
}
- public static X509CertificateImpl Import (byte[] rawData, string password, X509KeyStorageFlags keyStorageFlags)
+ static X509CertificateImpl ImportApple (byte[] rawData)
{
- MX.X509Certificate x509;
- IntPtr handle;
- if (password == null) {
- handle = CFHelpers.CreateCertificateFromData (rawData);
- if (handle != IntPtr.Zero)
- return new X509CertificateImplApple (handle, true);
+ var handle = CFHelpers.CreateCertificateFromData (rawData);
+ if (handle != IntPtr.Zero)
+ return new X509CertificateImplApple (handle, true);
+ MX.X509Certificate x509;
+ try {
+ x509 = new MX.X509Certificate (rawData);
+ } catch (Exception e) {
try {
- x509 = new MX.X509Certificate (rawData);
- } catch (Exception e) {
- try {
- x509 = X509Helper.ImportPkcs12 (rawData, null);
- } catch {
- string msg = Locale.GetText ("Unable to decode certificate.");
- // inner exception is the original (not second) exception
- throw new CryptographicException (msg, e);
- }
- }
- } else {
- // try PKCS#12
- try {
- x509 = X509Helper.ImportPkcs12 (rawData, password);
- }
- catch {
- // it's possible to supply a (unrequired/unusued) password
- // fix bug #79028
- x509 = new MX.X509Certificate (rawData);
+ x509 = ImportPkcs12 (rawData, null);
+ } catch {
+ string msg = Locale.GetText ("Unable to decode certificate.");
+ // inner exception is the original (not second) exception
+ throw new CryptographicException (msg, e);
}
}
}
}
}
+#endif