Exemple #1
0
 internal HttpListener(X509Certificate certificate, MSI.MonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
     : this()
 {
     this.certificate = certificate;
     this.tlsProvider = tlsProvider;
     this.tlsSettings = tlsSettings;
 }
        public override MSI.IMonoSslStream CreateSslStream(
            Stream innerStream, bool leaveInnerStreamOpen,
            MSI.MonoTlsSettings settings = null)
        {
            var impl = new Private.LegacySslStream(innerStream, leaveInnerStreamOpen, this, settings);

            return(new Private.MonoSslStreamImpl(impl));
        }
        public override MSI.IMonoSslStream CreateSslStream(
            Stream innerStream, bool leaveInnerStreamOpen,
            MSI.MonoTlsSettings settings = null)
        {
            var sslStream = CreateSslStreamImpl(innerStream, leaveInnerStreamOpen, settings);

            return(new MonoSslStreamImpl(sslStream));
        }
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen,
                                         MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            Settings = settings;
            Provider = provider;

            readBuffer  = new BufferOffsetSize2(16834);
            writeBuffer = new BufferOffsetSize2(16384);
        }
 MSI.IMonoTlsContext IMonoTlsProvider.CreateTlsContext(
     string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
     X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
     bool remoteCertRequired, bool checkCertName, bool checkCertRevocationStatus,
     MSI.MonoEncryptionPolicy encryptionPolicy, MSI.MonoTlsSettings settings)
 {
     return(CreateTlsContextImpl(
                hostname, serverMode, protocolFlags,
                serverCertificate, clientCertificates,
                remoteCertRequired, encryptionPolicy, settings));
 }
 internal override MSI.IMonoTlsContext CreateTlsContext(
     string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
     X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
     bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
     MSI.MonoTlsSettings settings)
 {
     return(CreateTlsContextImpl(
                hostname, serverMode, (MSI.TlsProtocols)protocolFlags,
                serverCertificate, clientCertificates,
                remoteCertRequired, (MSI.MonoEncryptionPolicy)encryptionPolicy,
                settings));
 }
Exemple #7
0
        public MobileAuthenticatedStream(Stream innerStream, bool leaveInnerStreamOpen, SslStream owner,
                                         MSI.MonoTlsSettings settings, MSI.MonoTlsProvider provider)
            : base(innerStream, leaveInnerStreamOpen)
        {
            SslStream = owner;
            Settings  = settings;
            Provider  = provider;

            readBuffer  = new BufferOffsetSize2(16500);
            writeBuffer = new BufferOffsetSize2(16384);
            operation   = Operation.None;
        }
        public IMonoSslStream CreateSslStream(
            Stream innerStream, bool leaveInnerStreamOpen,
            MSI.MonoTlsSettings settings)
        {
            var sslStream         = provider.CreateSslStream(innerStream, leaveInnerStreamOpen, settings);
            var monoSslStreamImpl = sslStream as MonoSslStreamImpl;

            if (monoSslStreamImpl != null)
            {
                return(monoSslStreamImpl.Impl);
            }
            return(new MonoSslStreamWrapper(sslStream));
        }
Exemple #9
0
        internal bool ChangeToSSLSocket(ref Stream stream)
        {
#if SECURITY_DEP
            var provider = MonoTlsProviderFactory.GetProviderInternal();
            var settings = new MSI.MonoTlsSettings();
            settings.UseServicePointManagerCallback = true;
            var sslStream = provider.CreateSslStream(stream, true, settings);
            sslStream.AuthenticateAsClient(requestUri.Host, null, SslProtocols.Default, false);
            stream = sslStream.AuthenticatedStream;
            return(true);
#else
            throw new NotImplementedException();
#endif
        }
Exemple #10
0
 internal IMonoSslStream CreateSslStream(Stream innerStream, bool ownsStream, MSI.MonoRemoteCertificateValidationCallback callback)
 {
     lock (registry) {
         if (tlsProvider == null)
         {
             tlsProvider = MonoTlsProviderFactory.GetProviderInternal();
         }
         if (tlsSettings == null)
         {
             tlsSettings = MSI.MonoTlsSettings.CopyDefaultSettings();
         }
         if (tlsSettings.RemoteCertificateValidationCallback == null)
         {
             tlsSettings.RemoteCertificateValidationCallback = callback;
         }
         return(tlsProvider.CreateSslStream(innerStream, ownsStream, tlsSettings));
     }
 }
 IMonoSslStream IMonoTlsProvider.CreateSslStream(
     Stream innerStream, bool leaveInnerStreamOpen,
     MSI.MonoTlsSettings settings)
 {
     return(CreateSslStreamImpl(innerStream, leaveInnerStreamOpen, settings));
 }
Exemple #12
0
		internal HttpListener (X509Certificate2 certificate, IMonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
			: this ()
		{
			this.certificate = certificate;
			this.tlsProvider = tlsProvider;
			this.tlsSettings = tlsSettings;
		}
Exemple #13
0
		internal IMonoSslStream CreateSslStream (Stream innerStream, bool ownsStream, MSI.MonoRemoteCertificateValidationCallback callback)
		{
			lock (registry) {
				if (tlsProvider == null)
					tlsProvider = MonoTlsProviderFactory.GetProviderInternal ();
				if (tlsSettings == null)
					tlsSettings = new MSI.MonoTlsSettings ();
				if (tlsSettings.RemoteCertificateValidationCallback == null)
					tlsSettings.RemoteCertificateValidationCallback = callback;
				return tlsProvider.CreateSslStream (innerStream, ownsStream, tlsSettings);
			}
		}
 protected abstract MSI.IMonoTlsContext CreateTlsContextImpl(
     string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
     X509Certificate serverCertificate, X509CertificateCollection clientCertificates,
     bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
     MSI.MonoTlsSettings settings);
Exemple #15
0
 public override MSI.IMonoSslStream CreateSslStream(
     Stream innerStream, bool leaveInnerStreamOpen,
     MSI.MonoTlsSettings settings = null)
 {
     return(SslStream.CreateMonoSslStream(innerStream, leaveInnerStreamOpen, this, settings));
 }
Exemple #16
0
 internal override MSI.IMonoSslStream CreateSslStreamInternal(
     SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen,
     MSI.MonoTlsSettings settings)
 {
     return(new Private.LegacySslStream(innerStream, leaveInnerStreamOpen, sslStream, this, settings));
 }
 protected abstract IMonoSslStream CreateSslStreamImpl(
     Stream innerStream, bool leaveInnerStreamOpen,
     MSI.MonoTlsSettings settings);
Exemple #18
0
 internal static HttpWebRequest CreateHttpsRequest(Uri requestUri, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
 {
     lock (locker) {
         var internalProvider = provider != null ? new Private.MonoTlsProviderWrapper(provider) : null;
         return(new HttpWebRequest(requestUri, internalProvider, settings));
     }
 }
Exemple #19
0
 internal static HttpListener CreateHttpListener(X509Certificate certificate, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
 {
     lock (locker) {
         var internalProvider = provider != null ? new Private.MonoTlsProviderWrapper(provider) : null;
         return(new HttpListener(certificate, internalProvider, settings));
     }
 }
Exemple #20
0
		private void InitiateSecureConnection () {
			SmtpResponse response = SendCommand ("STARTTLS");

			if (IsError (response)) {
				throw new SmtpException (SmtpStatusCode.GeneralFailure, "Server does not support secure connections.");
			}

#if SECURITY_DEP
			var tlsProvider = MonoTlsProviderFactory.GetProviderInternal ();
			var settings = new MSI.MonoTlsSettings ();
			settings.UseServicePointManagerCallback = true;
			var sslStream = tlsProvider.CreateSslStream (stream, false, settings);
			CheckCancellation ();
			sslStream.AuthenticateAsClient (Host, this.ClientCertificates, SslProtocols.Default, false);
			stream = sslStream.AuthenticatedStream;

#else
			throw new SystemException ("You are using an incomplete System.dll build");
#endif
		}