diff options
Diffstat (limited to 'tls.c')
| -rw-r--r-- | tls.c | 25 |
1 files changed, 25 insertions, 0 deletions
| @@ -0,0 +1,25 @@ | |||
| 1 | #include "exit.h" | ||
| 2 | #include "error.h" | ||
| 3 | #include <openssl/ssl.h> | ||
| 4 | #include <openssl/err.h> | ||
| 5 | |||
| 6 | int smtps = 0; | ||
| 7 | SSL *ssl = NULL; | ||
| 8 | |||
| 9 | void ssl_free(SSL *myssl) { SSL_shutdown(myssl); SSL_free(myssl); } | ||
| 10 | void ssl_exit(int status) { if (ssl) ssl_free(ssl); _exit(status); } | ||
| 11 | |||
| 12 | const char *ssl_error() | ||
| 13 | { | ||
| 14 | int r = ERR_get_error(); | ||
| 15 | if (!r) return NULL; | ||
| 16 | SSL_load_error_strings(); | ||
| 17 | return ERR_error_string(r, NULL); | ||
| 18 | } | ||
| 19 | const char *ssl_error_str() | ||
| 20 | { | ||
| 21 | const char *err = ssl_error(); | ||
| 22 | if (err) return err; | ||
| 23 | if (!errno) return 0; | ||
| 24 | return (errno == error_timeout) ? "timed out" : error_str(errno); | ||
| 25 | } | ||
