05.11.2013 Aufrufe

Zahn - Unix-Netzwerkprogramminerung mit Threads, Sockets und SSL

Zahn - Unix-Netzwerkprogramminerung mit Threads, Sockets und SSL

Zahn - Unix-Netzwerkprogramminerung mit Threads, Sockets und SSL

MEHR ANZEIGEN
WENIGER ANZEIGEN

Sie wollen auch ein ePaper? Erhöhen Sie die Reichweite Ihrer Titel.

YUMPU macht aus Druck-PDFs automatisch weboptimierte ePaper, die Google liebt.

98 {<br />

7.4 Client-/Server-Beispiel: SMTP <strong>mit</strong> SARTTLS 401<br />

99 char buf[256], res[256], *cmd, *arg, *tmp;<br />

100 int tls = 0;<br />

101<br />

102 send_smtp_response( bio,<br />

103 "220 manhattan.irgendwie -sowieso.dom ESMTP smtpsrv\n" );<br />

104<br />

105 while( BIO_gets( bio, buf, 256 ) > 0 )<br />

106 {<br />

107 if( ( cmd = strtok_r( buf, " \r\n", &tmp ) ) == NULL )<br />

108 continue; /* Leerzeile oder nur Whitespaces? */<br />

109 arg = strtok_r( NULL, " \r\n", &tmp );<br />

110<br />

111 if( strcasecmp( cmd, "EHLO" ) == 0 )<br />

112 {<br />

113 snprintf( res, 256,<br />

114 "250-manhattan.irgendwie -sowieso.dom Hello %s\n"<br />

115 "250-%s\n"<br />

116 "250 HELP\n",<br />

117 arg ? arg : "unknown", /* Nullzeiger abfangen! */<br />

118 tls ? "AUTH PLAIN LOGIN" : "STARTTLS" );<br />

119 send_smtp_response( bio, res );<br />

120 }<br />

121 else if( strcasecmp( cmd, "STARTTLS" ) == 0 )<br />

122 {<br />

123 if( tls )<br />

124 {<br />

125 send_smtp_response( bio,<br />

126 "503 STARTTLS not advertised\n" );<br />

127 }<br />

128 else<br />

129 {<br />

130 send_smtp_response( bio, "220 TLS go ahead\n" );<br />

131<br />

132 /* Socket -BIO-Kette in <strong>SSL</strong>-BIO-Kette umwandeln */<br />

133 if( ! ( bio = build_ssl_chain( bio ) ) )<br />

134 {<br />

135 syslog( LOG_ERR , "Can’t create <strong>SSL</strong> BIO.\n" );<br />

136 errors2syslog();<br />

137 break;<br />

138 }<br />

139<br />

140 tls = 1; /* Merker: Wir sprechen <strong>SSL</strong>/TLS! */<br />

141 }<br />

142 }<br />

143 else if( strcasecmp( cmd, "QUIT" ) == 0 )<br />

144 {<br />

145 send_smtp_response( bio, "221 closing connection\n" );<br />

146 break;

Hurra! Ihre Datei wurde hochgeladen und ist bereit für die Veröffentlichung.

Erfolgreich gespeichert!

Leider ist etwas schief gelaufen!