client->common.io = NULL;
}
- fd_ssl = ssl_proxy_new(client->common.fd);
+ fd_ssl = ssl_proxy_new(client->common.fd, &client->common.ip);
if (fd_ssl != -1) {
client->tls = TRUE;
client_set_title(client);
#include "../auth/auth-login-interface.h"
extern int disable_plaintext_auth, process_per_connection, verbose_proctitle;
+extern int verbose_ssl;
extern unsigned int max_logging_users;
extern unsigned int login_process_uid;
#include <syslog.h>
int disable_plaintext_auth, process_per_connection, verbose_proctitle;
+int verbose_ssl;
unsigned int max_logging_users;
unsigned int login_process_uid;
if (process_per_connection)
main_close_listen();
- fd_ssl = ssl_proxy_new(fd);
+ fd_ssl = ssl_proxy_new(fd, &ip);
if (fd_ssl == -1)
net_disconnect(fd);
else
disable_plaintext_auth = getenv("DISABLE_PLAINTEXT_AUTH") != NULL;
process_per_connection = getenv("PROCESS_PER_CONNECTION") != NULL;
- verbose_proctitle = getenv("VERBOSE_PROCTITLE") != NULL;
+ verbose_proctitle = getenv("VERBOSE_PROCTITLE") != NULL;
+ verbose_ssl = getenv("VERBOSE_SSL") != NULL;
value = getenv("MAX_LOGGING_USERS");
max_logging_users = value == NULL ? 0 : strtoul(value, NULL, 10);
int refcount;
gnutls_session session;
+ struct ip_addr ip;
+
int fd_ssl, fd_plain;
struct io *io_ssl, *io_plain;
int io_ssl_dir;
static int handle_ssl_error(struct ssl_proxy *proxy, int error)
{
if (!gnutls_error_is_fatal(error)) {
+ if (!verbose_ssl)
+ return 0;
+
if (error == GNUTLS_E_WARNING_ALERT_RECEIVED) {
- i_warning("Received SSL warning alert: %s",
- get_alert_text(proxy));
+ i_warning("Received SSL warning alert: %s [%s]",
+ get_alert_text(proxy),
+ net_ip2host(&proxy->ip));
+ } else {
+ i_warning("Non-fatal SSL error: %s: %s",
+ get_alert_text(proxy),
+ net_ip2host(&proxy->ip));
}
return 0;
}
- /* fatal error occured */
- if (error == GNUTLS_E_FATAL_ALERT_RECEIVED) {
- i_warning("Received SSL fatal alert: %s",
- get_alert_text(proxy));
- } else {
- i_warning("Error reading from SSL client: %s",
- gnutls_strerror(error));
+ if (verbose_ssl) {
+ /* fatal error occured */
+ if (error == GNUTLS_E_FATAL_ALERT_RECEIVED) {
+ i_warning("Received SSL fatal alert: %s [%s]",
+ get_alert_text(proxy),
+ net_ip2host(&proxy->ip));
+ } else {
+ i_warning("Error reading from SSL client: %s [%s]",
+ gnutls_strerror(error),
+ net_ip2host(&proxy->ip));
+ }
}
gnutls_alert_send_appropriate(proxy->session, error);
return session;
}
-int ssl_proxy_new(int fd)
+int ssl_proxy_new(int fd, struct ip_addr *ip)
{
struct ssl_proxy *proxy;
gnutls_session session;
proxy->session = session;
proxy->fd_ssl = fd;
proxy->fd_plain = sfd[0];
+ proxy->ip = *ip;
proxy->refcount++;
ssl_handshake(proxy);
int refcount;
SSL *ssl;
+ struct ip_addr ip;
enum ssl_state state;
int fd_ssl, fd_plain;
return buf;
}
-static void ssl_handle_error(struct ssl_proxy *proxy, int err, const char *func)
+static void ssl_handle_error(struct ssl_proxy *proxy, int ret, const char *func)
{
- err = SSL_get_error(proxy->ssl, err);
+ const char *errstr;
+ int err;
+
+ err = SSL_get_error(proxy->ssl, ret);
switch (err) {
case SSL_ERROR_WANT_READ:
break;
case SSL_ERROR_SYSCALL:
/* eat up the error queue */
- /*i_warning("%s failed: %s", func, ssl_last_error());*/
+ if (verbose_ssl) {
+ if (ERR_peek_error() != 0)
+ errstr = ssl_last_error();
+ else {
+ if (ret == 0)
+ errstr = "EOF";
+ else
+ errstr = strerror(errno);
+ }
+
+ i_warning("%s syscall failed: %s [%s]",
+ func, errstr, net_ip2host(&proxy->ip));
+ }
ssl_proxy_destroy(proxy);
break;
case SSL_ERROR_ZERO_RETURN:
ssl_proxy_destroy(proxy);
break;
case SSL_ERROR_SSL:
- /*i_warning("%s failed: %s", func, ssl_last_error());*/
+ if (verbose_ssl) {
+ i_warning("%s failed: %s [%s]", func, ssl_last_error(),
+ net_ip2host(&proxy->ip));
+ }
ssl_proxy_destroy(proxy);
break;
default:
- i_warning("%s failed: unknown failure %d (%s)",
- func, err, ssl_last_error());
+ i_warning("%s failed: unknown failure %d (%s) [%s]",
+ func, err, ssl_last_error(), net_ip2host(&proxy->ip));
ssl_proxy_destroy(proxy);
break;
}
proxy->io_ssl_dir = dir;
}
-int ssl_proxy_new(int fd)
+int ssl_proxy_new(int fd, struct ip_addr *ip)
{
struct ssl_proxy *proxy;
SSL *ssl;
proxy->ssl = ssl;
proxy->fd_ssl = fd;
proxy->fd_plain = sfd[0];
+ proxy->ip = *ip;
proxy->state = SSL_STATE_HANDSHAKE;
ssl_set_direction(proxy, IO_READ);
#ifndef __SSL_PROXY_H
#define __SSL_PROXY_H
+struct ip_addr;
+
extern int ssl_initialized;
/* establish SSL connection with the given fd, returns a new fd which you
must use from now on, or -1 if error occured. Unless -1 is returned,
the given fd must be simply forgotten. */
-int ssl_proxy_new(int fd);
+int ssl_proxy_new(int fd, struct ip_addr *ip);
void ssl_proxy_init(void);
void ssl_proxy_deinit(void);
/* login */
DEF(SET_STR, login_dir),
DEF(SET_BOOL, login_chroot),
+ DEF(SET_BOOL, verbose_ssl),
/* mail */
DEF(SET_STR, valid_chroot_dirs),
/* login */
MEMBER(login_dir) "login",
MEMBER(login_chroot) TRUE,
+ MEMBER(verbose_ssl) FALSE,
/* mail */
MEMBER(valid_chroot_dirs) NULL,
/* login */
const char *login_dir;
int login_chroot;
+ int verbose_ssl;
/* mail */
const char *valid_chroot_dirs;
client->common.io = NULL;
}
- fd_ssl = ssl_proxy_new(client->common.fd);
+ fd_ssl = ssl_proxy_new(client->common.fd, &client->common.ip);
if (fd_ssl != -1) {
client->tls = TRUE;
client_set_title(client);