Esempio n. 1
0
 public override byte[] Export(X509ContentType contentType, string password)
 {
     X509Helper.ThrowIfContextInvalid(Impl);
     using (var handle = new SafePasswordHandle(password)) {
         return(Impl.Export(contentType, handle));
     }
 }
Esempio n. 2
0
        // strangly there are no DateTime returning function
        public virtual string GetExpirationDateString()
        {
            if (hideDates)
            {
                return(null);
            }
            X509Helper.ThrowIfContextInvalid(impl);

            return(impl.GetValidUntil().ToLocalTime().ToString());
        }
Esempio n. 3
0
        // strangly there are no DateTime returning function
        public virtual string GetEffectiveDateString()
        {
            if (hideDates)
            {
                return(null);
            }
            X509Helper.ThrowIfContextInvalid(impl);

            return(impl.GetValidFrom().ToLocalTime().ToString());
        }
Esempio n. 4
0
        internal static void ExportAsPEM(X509Certificate certificate, Stream stream, bool includeHumanReadableForm)
        {
#if MONO_FEATURE_BTLS
            X509Helper.ThrowIfContextInvalid(certificate.Impl);
            using (var x509 = GetNativeInstance(certificate.Impl))
                using (var bio = MonoBtlsBio.CreateMonoStream(stream))
                    x509.ExportAsPEM(bio, includeHumanReadableForm);
#else
            throw new PlatformNotSupportedException();
#endif
        }
Esempio n. 5
0
        internal static long GetSubjectNameHash(X509Certificate certificate)
        {
#if MONO_FEATURE_BTLS
            X509Helper.ThrowIfContextInvalid(certificate.Impl);
            using (var x509 = GetNativeInstance(certificate.Impl))
                using (var subject = x509.GetSubjectName())
                    return(subject.GetHash());
#else
            throw new PlatformNotSupportedException();
#endif
        }
Esempio n. 6
0
        public virtual byte[] GetKeyAlgorithmParameters()
        {
            X509Helper.ThrowIfContextInvalid(impl);

            byte[] kap = impl.GetKeyAlgorithmParameters();
            if (kap == null)
            {
                throw new CryptographicException(Locale.GetText("Parameters not part of the certificate"));
            }

            return(kap);
        }
Esempio n. 7
0
        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;
        }
Esempio n. 8
0
 internal byte[] Export(X509ContentType contentType, byte[] password)
 {
     try {
         X509Helper.ThrowIfContextInvalid(impl);
         return(impl.Export(contentType, password));
     } finally {
         // protect password
         if (password != null)
         {
             Array.Clear(password, 0, password.Length);
         }
     }
 }
Esempio n. 9
0
        static MonoBtlsX509 GetNativeInstance(X509CertificateImpl impl)
        {
            X509Helper.ThrowIfContextInvalid(impl);
            var btlsImpl = impl as X509CertificateImplBtls;

            if (btlsImpl != null)
            {
                return(btlsImpl.X509.Copy());
            }
            else
            {
                return(MonoBtlsX509.LoadFromData(impl.GetRawCertData(), MonoBtlsX509Format.DER));
            }
        }
Esempio n. 10
0
 public virtual byte[] GetSerialNumber()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(impl.GetSerialNumber());
 }
Esempio n. 11
0
 public virtual string GetRawCertDataString()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(X509Helper.ToHexString(impl.GetRawCertData()));
 }
Esempio n. 12
0
 public virtual byte[] GetRawCertData()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(impl.GetRawCertData());
 }
Esempio n. 13
0
 public virtual string GetName()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(impl.GetSubjectName(true));
 }
Esempio n. 14
0
 public virtual string GetKeyAlgorithm()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(impl.GetKeyAlgorithm());
 }
Esempio n. 15
0
 public virtual byte[] Export(X509ContentType contentType, SecureString password)
 {
     X509Helper.ThrowIfContextInvalid(impl);
     using (var handle = new SafePasswordHandle(password))
         return(impl.Export(contentType, handle));
 }
 internal static void ThrowIfContextInvalid(X509CertificateImpl impl)
 {
     X509Helper.ThrowIfContextInvalid(impl);
 }
Esempio n. 17
0
 internal void ThrowIfInvalid()
 {
     X509Helper.ThrowIfContextInvalid(impl);
 }
Esempio n. 18
0
 public virtual byte[] GetPublicKey()
 {
     X509Helper.ThrowIfContextInvalid(impl);
     return(impl.GetPublicKey());
 }