コード例 #1
0
ファイル: SmtpClient.cs プロジェクト: nlhepler/mono
		// make the actual connection
		// and HELO handshaking
		void Connect ()
		{
			tcpConnection = new TcpClient (server, port);
	    
			NetworkStream stream = tcpConnection.GetStream ();
			smtp = new SmtpStream (stream);
		}
コード例 #2
0
        void ChangeToSSLSocket()
        {
#if TARGET_JVM
            java.lang.Class          c = vmw.common.TypeUtils.ToClass(smtp.Stream);
            java.lang.reflect.Method m = c.getMethod("ChangeToSSLSocket", null);
            m.invoke(smtp.Stream, new object[] {});
#else
            // Load Mono.Security.dll
            Assembly a;
            try
            {
                a = Assembly.Load(Consts.AssemblyMono_Security);
            }
            catch (System.IO.FileNotFoundException)
            {
                throw new SmtpException("Cannot load Mono.Security.dll");
            }
            Type     tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream");
            object[] consArgs         = new object[4];
            consArgs[0] = smtp.Stream;
            consArgs[1] = server;
            consArgs[2] = true;
            Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType");
            int  nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3");
            int  nTlsVal  = (int)Enum.Parse(tSecurityProtocolType, "Tls");
            consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal);

            object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs);

            if (objSslClientStream != null)
            {
                smtp = new SmtpStream((Stream)objSslClientStream);
            }
#endif
        }
コード例 #3
0
        void ChangeToSSLSocket()
        {
            var sslStream = new SslStream(smtp.Stream);

            sslStream.AuthenticateAsClient(server);
            smtp = new SmtpStream(sslStream);
        }
コード例 #4
0
        void ChangeToSSLSocket()
        {
            // Load Mono.Security.dll
            Assembly a;

            try {
                a = Assembly.Load(Consts.AssemblyMono_Security);
            } catch (System.IO.FileNotFoundException) {
                throw new SmtpException("Cannot load Mono.Security.dll");
            }
            Type tSslClientStream = a.GetType("Mono.Security.Protocol.Tls.SslClientStream");

            object[] consArgs = new object[4];
            consArgs[0] = smtp.Stream;
            consArgs[1] = server;
            consArgs[2] = true;
            Type tSecurityProtocolType = a.GetType("Mono.Security.Protocol.Tls.SecurityProtocolType");
            int  nSsl3Val = (int)Enum.Parse(tSecurityProtocolType, "Ssl3");
            int  nTlsVal  = (int)Enum.Parse(tSecurityProtocolType, "Tls");

            consArgs[3] = Enum.ToObject(tSecurityProtocolType, nSsl3Val | nTlsVal);

            object objSslClientStream = Activator.CreateInstance(tSslClientStream, consArgs);

            if (objSslClientStream != null)
            {
                smtp = new SmtpStream((Stream)objSslClientStream);
            }
        }
コード例 #5
0
        // make the actual connection
        // and HELO handshaking
        void Connect()
        {
            tcpConnection = new TcpClient(server, port);

            NetworkStream stream = tcpConnection.GetStream();

            smtp = new SmtpStream(stream);
        }
コード例 #6
0
	// make the actual connection
	// and HELO handshaking
	private void Connect() {
	    tcpConnection = new TcpClient( server , 25 );
	    
	    Stream stream = tcpConnection.GetStream();
	    smtp = new SmtpStream( stream );
	    
	    // read the server greeting
	    smtp.ReadResponse();
	    smtp.CheckForStatusCode( 220 );
	   
	    // write the HELO command to the server
	    smtp.WriteHelo( Dns.GetHostName() );
	    	    
	}
コード例 #7
0
ファイル: SmtpClient.cs プロジェクト: nlhepler/mono
		void ChangeToSSLSocket ()
		{
			// Load Mono.Security.dll
			Assembly a;
			try {
				a = Assembly.Load (Consts.AssemblyMono_Security);
			} catch (System.IO.FileNotFoundException) {
				throw new SmtpException ("Cannot load Mono.Security.dll");
			}
			Type tSslClientStream = a.GetType ("Mono.Security.Protocol.Tls.SslClientStream");
			object[] consArgs = new object[4];
			consArgs[0] = smtp.Stream;
			consArgs[1] = server;
			consArgs[2] = true;
			Type tSecurityProtocolType = a.GetType ("Mono.Security.Protocol.Tls.SecurityProtocolType");
			int nSsl3Val = (int) Enum.Parse (tSecurityProtocolType, "Ssl3");
			int nTlsVal = (int) Enum.Parse (tSecurityProtocolType, "Tls");
			consArgs[3] = Enum.ToObject (tSecurityProtocolType, nSsl3Val | nTlsVal);

			object objSslClientStream = Activator.CreateInstance (tSslClientStream, consArgs); 

			if (objSslClientStream != null)
				smtp = new SmtpStream ((Stream)objSslClientStream);
		}
コード例 #8
0
ファイル: SmtpClient.cs プロジェクト: carrie901/mono
		void ChangeToSSLSocket ()
		{
#if TARGET_JVM
			java.lang.Class c = vmw.common.TypeUtils.ToClass (smtp.Stream);
			java.lang.reflect.Method m = c.getMethod ("ChangeToSSLSocket", null);
			m.invoke (smtp.Stream, new object[]{});
#else
			// Load Mono.Security.dll
			Assembly a;
			try {
				a = Assembly.Load (Consts.AssemblyMono_Security);
			} catch (System.IO.FileNotFoundException) {
				throw new SmtpException ("Cannot load Mono.Security.dll");
			}
			Type tSslClientStream = a.GetType ("Mono.Security.Protocol.Tls.SslClientStream");
			object[] consArgs = new object[4];
			consArgs[0] = smtp.Stream;
			consArgs[1] = server;
			consArgs[2] = true;
			Type tSecurityProtocolType = a.GetType ("Mono.Security.Protocol.Tls.SecurityProtocolType");
			int nSsl3Val = (int) Enum.Parse (tSecurityProtocolType, "Ssl3");
			int nTlsVal = (int) Enum.Parse (tSecurityProtocolType, "Tls");
			consArgs[3] = Enum.ToObject (tSecurityProtocolType, nSsl3Val | nTlsVal);

			object objSslClientStream = Activator.CreateInstance (tSslClientStream, consArgs); 

			if (objSslClientStream != null)
				smtp = new SmtpStream ((Stream)objSslClientStream);
#endif
		}