summaryrefslogtreecommitdiff
path: root/tls.c
diff options
context:
space:
mode:
authorJohn Denker <jsd@av8n.com>2016-01-01 11:17:17 -0700
committerJohn Denker <jsd@av8n.com>2016-01-01 16:34:35 -0800
commit0fefe3a661fb5155f811d5a6412194a566f7de0a (patch)
tree11a712a24d842e9eeb58afcce80fcf75742ba121 /tls.c
parent67c1e178e1f1d171181e574186468b68a810ee25 (diff)
newly created files now added to repo
Diffstat (limited to 'tls.c')
-rw-r--r--tls.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/tls.c b/tls.c
new file mode 100644
index 0000000..aed5d57
--- /dev/null
+++ b/tls.c
@@ -0,0 +1,25 @@
+#include "exit.h"
+#include "error.h"
+#include <openssl/ssl.h>
+#include <openssl/err.h>
+
+int smtps = 0;
+SSL *ssl = NULL;
+
+void ssl_free(SSL *myssl) { SSL_shutdown(myssl); SSL_free(myssl); }
+void ssl_exit(int status) { if (ssl) ssl_free(ssl); _exit(status); }
+
+const char *ssl_error()
+{
+ int r = ERR_get_error();
+ if (!r) return NULL;
+ SSL_load_error_strings();
+ return ERR_error_string(r, NULL);
+}
+const char *ssl_error_str()
+{
+ const char *err = ssl_error();
+ if (err) return err;
+ if (!errno) return 0;
+ return (errno == error_timeout) ? "timed out" : error_str(errno);
+}