// make the actual connection // and HELO handshaking void Connect () { tcpConnection = new TcpClient (server, port); NetworkStream stream = tcpConnection.GetStream (); smtp = new SmtpStream (stream); }
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 }
void ChangeToSSLSocket() { var sslStream = new SslStream(smtp.Stream); sslStream.AuthenticateAsClient(server); smtp = new SmtpStream(sslStream); }
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); } }
// make the actual connection // and HELO handshaking void Connect() { tcpConnection = new TcpClient(server, port); NetworkStream stream = tcpConnection.GetStream(); smtp = new SmtpStream(stream); }
// 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() ); }
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); }
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 }