public static SslCertificateTrust CreateForX509Store(X509Store store, bool sendTrustInHandshake = false)
        {
#if TARGET_WINDOWS
            if (sendTrustInHandshake && store.Location != StoreLocation.LocalMachine)
            {
                throw new PlatformNotSupportedException(SR.net_ssl_trust_store);
            }
#endif
            if (sendTrustInHandshake && !System.OperatingSystem.IsLinux() && !System.OperatingSystem.IsMacOS() &&
                // Necessary functions are available only on win 8 onwards
                !OperatingSystem.IsWindowsVersionAtLeast(6, 2))
            {
                // to be removed when implemented.
                throw new PlatformNotSupportedException(SR.net_ssl_trust_handshake);
            }
            if (!store.IsOpen)
            {
                store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
            }

            var trust = new SslCertificateTrust();
            trust._store = store;
            trust._sendTrustInHandshake = sendTrustInHandshake;
            return(trust);
        }
Example #2
0
        public static SslCertificateTrust CreateForX509Collection(X509Certificate2Collection trustList, bool sendTrustInHandshake = false)
        {
            if (sendTrustInHandshake && !System.OperatingSystem.IsLinux() && !System.OperatingSystem.IsMacOS())
            {
                throw new PlatformNotSupportedException(SR.net_ssl_trust_handshake);
            }

            var trust = new SslCertificateTrust();

            trust._trustList            = trustList;
            trust._sendTrustInHandshake = sendTrustInHandshake;
            return(trust);
        }
        public static SslCertificateTrust CreateForX509Collection(X509Certificate2Collection trustList, bool sendTrustInHandshake = false)
        {
            if (sendTrustInHandshake && !System.OperatingSystem.IsLinux() && !System.OperatingSystem.IsMacOS())
            {
                // to be removed when implemented.
                throw new PlatformNotSupportedException(SR.net_ssl_trust_handshake);
            }

#if TARGET_WINDOWS
            if (sendTrustInHandshake)
            {
                throw new PlatformNotSupportedException(SR.net_ssl_trust_collection);
            }
#endif
            var trust = new SslCertificateTrust();
            trust._trustList            = trustList;
            trust._sendTrustInHandshake = sendTrustInHandshake;
            return(trust);
        }
Example #4
0
        public static SslCertificateTrust CreateForX509Store(X509Store store, bool sendTrustInHandshake = false)
        {
#if TARGET_WINDOWS
            if (sendTrustInHandshake && store.Location != StoreLocation.LocalMachine)
            {
                throw new PlatformNotSupportedException(SR.net_ssl_trust_store);
            }
#else
            if (sendTrustInHandshake)
            {
                // to be removed when implemented.
                throw new PlatformNotSupportedException("Not supported yet.");
            }
#endif
            if (!store.IsOpen)
            {
                store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
            }

            var trust = new SslCertificateTrust();
            trust._store = store;
            trust._sendTrustInHandshake = sendTrustInHandshake;
            return(trust);
        }