2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 1999-2001 Hiroyuki Yamamoto
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 SSL_load_error_strings();
38 ssl_ctx = SSL_CTX_new(SSLv23_client_method());
40 debug_print(_("SSL disabled\n"));
42 debug_print(_("SSL loaded\n"));
50 SSL_CTX_free(ssl_ctx);
53 gboolean ssl_init_socket(SockInfo *sockinfo) {
57 log_warning(_("SSL not available\n"));
62 sockinfo->ssl = SSL_new(ssl_ctx);
63 if(sockinfo->ssl == NULL) {
64 log_warning(_("Error creating ssl context\n"));
69 SSL_set_fd(sockinfo->ssl, sockinfo->sock);
70 if(SSL_connect(sockinfo->ssl) == -1) {
71 log_warning(_("SSL connect failed\n"));
78 log_print(_("SSL connection using %s\n"), SSL_get_cipher(sockinfo->ssl));
80 /* Get server's certificate (note: beware of dynamic allocation) */
82 if((server_cert = SSL_get_peer_certificate(sockinfo->ssl)) != NULL) {
85 log_print(_("Server certificate:\n"));
87 if((str = X509_NAME_oneline(X509_get_subject_name (server_cert),0,0)) != NULL) {
88 log_print(_(" Subject: %s\n"), str);
92 if((str = X509_NAME_oneline(X509_get_issuer_name (server_cert),0,0)) != NULL) {
93 log_print(_(" Issuer: %s\n"), str);
97 X509_free(server_cert);
101 void ssl_done_socket(SockInfo *sockinfo) {
103 SSL_free(sockinfo->ssl);