public static X509CertificateImpl InitFromCertificate(X509CertificateImpl impl) { if (impl == null) { return(null); } var copy = impl.Clone(); if (copy != null) { return(copy); } var data = impl.GetRawCertData(); if (data == null) { return(null); } var x509 = new MX.X509Certificate(data); return(new X509CertificateImplMono(x509)); }
internal static void ThrowIfContextInvalid(X509CertificateImpl impl) { if (!IsValid(impl)) { throw GetInvalidContextException(); } }
public X509Certificate(byte[] data) { if (data != null && data.Length != 0) { impl = X509Helper.Import(data); } }
public void Add(X509CertificateImpl impl, bool takeOwnership) { if (!takeOwnership) { impl = impl.Clone(); } list.Add(impl); }
public X509Certificate(IntPtr handle) { if (handle == IntPtr.Zero) { throw new ArgumentException("Invalid handle."); } impl = X509Helper.InitFromHandle(handle); }
public X509CertificateMono(X509CertificateMono cert) { if (cert == null) { throw new ArgumentNullException("cert"); } impl = X509Helper.InitFromCertificate(cert); }
public X509Certificate(byte[] data) { if (data != null && data.Length != 0) { // For compat reasons, this constructor treats passing a null or empty data set as the same as calling the nullary constructor. using (var safePasswordHandle = new SafePasswordHandle((string)null)) impl = X509Helper.Import(data, safePasswordHandle, X509KeyStorageFlags.DefaultKeySet); } }
internal static void ExportAsPEM (X509CertificateImpl impl, Stream stream, bool includeHumanReadableForm) { #if SECURITY_DEP using (var x509 = GetNativeInstance (impl)) ExportAsPEM (x509, stream, includeHumanReadableForm); #else throw new NotSupportedException (); #endif }
internal static long GetSubjectNameHash (X509CertificateImpl impl) { #if SECURITY_DEP using (var x509 = GetNativeInstance (impl)) return GetSubjectNameHash (x509); #else throw new NotSupportedException (); #endif }
internal X509Certificate(X509CertificateImpl impl) { if (impl == null) { throw new ArgumentNullException("impl"); } this.impl = X509Helper.InitFromCertificate(impl); }
internal static long GetSubjectNameHash(X509CertificateImpl impl) { #if SECURITY_DEP using (var x509 = GetNativeInstance(impl)) return(GetSubjectNameHash(x509)); #else throw new NotSupportedException(); #endif }
internal static void ExportAsPEM(X509CertificateImpl impl, Stream stream, bool includeHumanReadableForm) { #if SECURITY_DEP using (var x509 = GetNativeInstance(impl)) ExportAsPEM(x509, stream, includeHumanReadableForm); #else throw new NotSupportedException(); #endif }
public X509Certificate(X509Certificate cert) { if (cert == null) { throw new ArgumentNullException(nameof(cert)); } impl = X509Helper.InitFromCertificate(cert); }
public X509Certificate(System.Security.Cryptography.X509Certificates.X509Certificate cert) { if (cert == null) { throw new ArgumentNullException("cert"); } impl = X509Helper.InitFromCertificate(cert); hideDates = false; }
void MustFallback() { ThrowIfContextInvalid(); if (fallback != null) { return; } var mxCert = new MX.X509Certificate(GetRawCertData()); fallback = new X509CertificateImplMono(mxCert); }
public override bool Equals (X509CertificateImpl other, out bool result) { var otherAppleImpl = other as X509CertificateImplApple; if (otherAppleImpl != null && otherAppleImpl.handle == handle) { result = true; return true; } result = false; return false; }
public X509Certificate(byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags) { if (rawData == null || rawData.Length == 0) { throw new ArgumentException(SR.Arg_EmptyOrNullArray, nameof(rawData)); } ValidateKeyStorageFlags(keyStorageFlags); using (var safePasswordHandle = new SafePasswordHandle(password)) impl = X509Helper.Import(rawData, safePasswordHandle, keyStorageFlags); }
public override bool Equals(X509CertificateImpl other, out bool result) { var otherAppleImpl = other as X509CertificateImplApple; if (otherAppleImpl != null && otherAppleImpl.handle == handle) { result = true; return(true); } result = false; return(false); }
protected override void Dispose(bool disposing) { if (handle != IntPtr.Zero) { CFHelpers.CFRelease(handle); handle = IntPtr.Zero; } if (fallback != null) { fallback.Dispose(); fallback = null; } }
public static X509CertificateImpl InitFromCertificate (X509CertificateImpl impl) { ThrowIfContextInvalid (impl); var copy = impl.Clone (); if (copy != null) return copy; var data = impl.GetRawCertData (); if (data == null) return null; var x509 = new MX.X509Certificate (data); return new X509CertificateImplMono (x509); }
public X509Certificate(string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags) : this() { if (fileName == null) { throw new ArgumentNullException(nameof(fileName)); } ValidateKeyStorageFlags(keyStorageFlags); var rawData = File.ReadAllBytes(fileName); using (var safePasswordHandle = new SafePasswordHandle(password)) impl = X509Helper.Import(rawData, safePasswordHandle, keyStorageFlags); }
static MonoBtlsX509 GetNativeInstance(X509CertificateImpl impl) { ThrowIfContextInvalid(impl); var btlsImpl = impl as X509CertificateImplBtls; if (btlsImpl != null) { return(btlsImpl.X509.Copy()); } else { return(MonoBtlsX509.LoadFromData(impl.GetRawCertData(), MonoBtlsX509Format.DER)); } }
public virtual void Reset() { if (impl != null) { impl.Dispose(); impl = null; } lazyCertHash = null; lazyIssuer = null; lazySubject = null; lazySerialNumber = null; lazyKeyAlgorithm = null; lazyKeyAlgorithmParameters = null; lazyPublicKey = null; lazyNotBefore = DateTime.MinValue; lazyNotAfter = DateTime.MinValue; }
// public methods public virtual bool Equals(System.Security.Cryptography.X509Certificates.X509Certificate other) { if (other == null) { return(false); } else { if (!X509Helper.IsValid(other.impl)) { if (!X509Helper.IsValid(impl)) { return(true); } throw new CryptographicException(Locale.GetText("Certificate instance is empty.")); } return(X509CertificateImpl.Equals(impl, other.impl)); } }
public static bool Equals(X509CertificateImpl first, X509CertificateImpl second) { if (!IsValid(first) || !IsValid(second)) { return(false); } bool result; if (first.Equals(second, out result)) { return(result); } var firstRaw = first.RawData; var secondRaw = second.RawData; if (firstRaw == null) { return(secondRaw == null); } else if (secondRaw == null) { return(false); } if (firstRaw.Length != secondRaw.Length) { return(false); } for (int i = 0; i < firstRaw.Length; i++) { if (firstRaw [i] != secondRaw [i]) { return(false); } } return(true); }
protected override void Dispose (bool disposing) { if (handle != IntPtr.Zero){ CFHelpers.CFRelease (handle); handle = IntPtr.Zero; } if (fallback != null) { fallback.Dispose (); fallback = null; } }
public override bool Equals (X509CertificateImpl other, out bool result) { // Use default implementation result = false; return false; }
public static byte[] Export(X509CertificateImpl impl, X509ContentType contentType, SafePasswordHandle password) { ThrowIfContextInvalid(impl); return(impl.Export(contentType, password)); }
public override bool Equals (X509CertificateImpl other, out bool result) { var otherBoringImpl = other as X509CertificateImplBtls; if (otherBoringImpl == null) { result = false; return false; } result = MonoBtlsX509.Compare (X509, otherBoringImpl.X509) == 0; return true; }
internal X509Certificate (X509CertificateImpl impl) { if (impl == null) throw new ArgumentNullException ("impl"); this.impl = X509Helper.InitFromCertificate (impl); }
public static bool IsValid(X509CertificateImpl impl) { return(impl != null && impl.IsValid); }
internal static void ThrowIfContextInvalid (X509CertificateImpl impl) { if (!IsValid (impl)) throw GetInvalidContextException (); }
internal void ImportHandle (X509CertificateImpl impl) { Reset (); this.impl = impl; }
internal static void ThrowIfContextInvalid (X509CertificateImpl impl) { X509Helper.ThrowIfContextInvalid (impl); }
public static bool IsValid (X509CertificateImpl impl) { return impl != null && impl.IsValid; }
public static bool Equals (X509CertificateImpl first, X509CertificateImpl second) { if (!IsValid (first) || !IsValid (second)) return false; bool result; if (first.Equals (second, out result)) return result; var firstRaw = first.GetRawCertData (); var secondRaw = second.GetRawCertData (); if (firstRaw == null) return secondRaw == null; else if (secondRaw == null) return false; if (firstRaw.Length != secondRaw.Length) return false; for (int i = 0; i < firstRaw.Length; i++) { if (firstRaw [i] != secondRaw [i]) return false; } return true; }
public static byte[] Export (X509CertificateImpl impl, X509ContentType contentType, byte[] password) { ThrowIfContextInvalid (impl); return impl.Export (contentType, password); }
static X509Certificate GetNativeInstance(X509CertificateImpl impl) { throw new PlatformNotSupportedException(); }
public virtual void Import(byte[] rawData, SecureString password, X509KeyStorageFlags keyStorageFlags) { using (var safePasswordHandle = new SafePasswordHandle(password)) impl = X509Helper.Import(rawData, safePasswordHandle, keyStorageFlags); }
public X509Certificate (IntPtr handle) { if (handle == IntPtr.Zero) throw new ArgumentException ("Invalid handle."); impl = X509Helper.InitFromHandle (handle); }
public virtual void Import(string fileName, SecureString password, X509KeyStorageFlags keyStorageFlags) { byte[] rawData = File.ReadAllBytes(fileName); using (var safePasswordHandle = new SafePasswordHandle(password)) impl = X509Helper.Import(rawData, safePasswordHandle, keyStorageFlags); }
public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert) { if (cert == null) throw new ArgumentNullException ("cert"); X509Helper.ThrowIfContextInvalid (cert.impl); impl = X509Helper.InitFromCertificate (cert.impl); hideDates = false; }
internal void ImportHandle(X509CertificateImpl impl) { Reset(); this.impl = impl; }
public override bool Equals(X509CertificateImpl other, out bool result) { // Use default implementation result = false; return(false); }
public static X509CertificateImpl InitFromCertificate(X509CertificateImpl impl) { return(impl?.Clone()); }
void MustFallback () { ThrowIfContextInvalid (); if (fallback != null) return; var mxCert = new MX.X509Certificate (GetRawCertData ()); fallback = new X509CertificateImplMono (mxCert); }
static X509Certificate GetNativeInstance (X509CertificateImpl impl) { throw new PlatformNotSupportedException (); }
internal X509Certificate(X509CertificateImpl impl) { Debug.Assert(impl != null); this.impl = X509Helper.InitFromCertificate(impl); }
public void Add (X509CertificateImpl impl, bool takeOwnership) { if (!takeOwnership) impl = impl.Clone (); list.Add (impl); }
static MonoBtlsX509 GetNativeInstance (X509CertificateImpl impl) { ThrowIfContextInvalid (impl); var btlsImpl = impl as X509CertificateImplBtls; if (btlsImpl != null) return btlsImpl.X509.Copy (); else return MonoBtlsX509.LoadFromData (impl.GetRawCertData (), MonoBtlsX509Format.DER); }