mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-07 22:31:59 +01:00
use init_ssl from misc.c in unit_tests/smtp.c
Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
parent
d97e653e8c
commit
2c3f29db44
@ -96,7 +96,7 @@ int connect_to_imap_server(struct data *data){
|
||||
data->import->cap_uidplus = 0;
|
||||
|
||||
if(data->net->use_ssl == 1){
|
||||
init_ssl_to_server(data);
|
||||
init_ssl(data);
|
||||
}
|
||||
|
||||
|
||||
|
@ -730,7 +730,7 @@ int read_one_line(char *s, int c, char *buf, int buflen, int *rc){
|
||||
}
|
||||
|
||||
|
||||
int init_ssl_to_server(struct data *data){
|
||||
int init_ssl(struct data *data){
|
||||
int n;
|
||||
X509* server_cert;
|
||||
char *str;
|
||||
|
@ -51,7 +51,7 @@ int can_i_write_directory(char *dir);
|
||||
void move_email(struct smtp_session *session);
|
||||
int read_one_line(char *s, int c, char *buf, int buflen, int *rc);
|
||||
|
||||
int init_ssl_to_server(struct data *data);
|
||||
int init_ssl(struct data *data);
|
||||
|
||||
#ifndef _GNU_SOURCE
|
||||
char *strcasestr(const char *s, const char *find);
|
||||
|
@ -37,7 +37,7 @@ int connect_to_pop3_server(struct data *data){
|
||||
char buf[MAXBUFSIZE];
|
||||
|
||||
if(data->net->use_ssl == 1){
|
||||
init_ssl_to_server(data);
|
||||
init_ssl(data);
|
||||
}
|
||||
|
||||
recvtimeoutssl(data->net, buf, sizeof(buf));
|
||||
|
@ -108,49 +108,6 @@ void send_helo_command(struct net *net){
|
||||
}
|
||||
|
||||
|
||||
int init_ssl(struct data *data){
|
||||
int n;
|
||||
char *str;
|
||||
X509* server_cert;
|
||||
|
||||
SSL_library_init();
|
||||
SSL_load_error_strings();
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L
|
||||
data->net->ctx = SSL_CTX_new(TLSv1_client_method());
|
||||
#else
|
||||
data->net->ctx = SSL_CTX_new(TLS_client_method());
|
||||
#endif
|
||||
CHK_NULL(data->net->ctx, "internal SSL error");
|
||||
|
||||
data->net->ssl = SSL_new(data->net->ctx);
|
||||
CHK_NULL(data->net->ssl, "internal ssl error");
|
||||
|
||||
SSL_set_fd(data->net->ssl, data->net->socket);
|
||||
n = SSL_connect(data->net->ssl);
|
||||
CHK_SSL(n, "internal ssl error");
|
||||
|
||||
printf("Cipher: %s\n", SSL_get_cipher(data->net->ssl));
|
||||
|
||||
server_cert = SSL_get_peer_certificate(data->net->ssl);
|
||||
CHK_NULL(server_cert, "server cert error");
|
||||
|
||||
str = X509_NAME_oneline(X509_get_subject_name(server_cert), 0, 0);
|
||||
CHK_NULL(str, "error in server cert");
|
||||
OPENSSL_free(str);
|
||||
|
||||
str = X509_NAME_oneline(X509_get_issuer_name(server_cert), 0, 0);
|
||||
CHK_NULL(str, "error in server cert");
|
||||
OPENSSL_free(str);
|
||||
|
||||
X509_free(server_cert);
|
||||
|
||||
data->net->use_ssl = 1;
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
static void test_smtp_commands_one_at_a_time(char *server, int port, struct data *data){
|
||||
char recvbuf[MAXBUFSIZE], sendbuf[MAXBUFSIZE];
|
||||
|
||||
@ -285,6 +242,7 @@ static void test_smtp_commands_starttls(char *server, int port, struct data *dat
|
||||
assert(strncmp(recvbuf, "220 ", 4) == 0 && "STARTTLS");
|
||||
|
||||
init_ssl(data);
|
||||
data->net->use_ssl = 1;
|
||||
|
||||
send_helo_command(data->net);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user