diff --git a/lib3270.cbp b/lib3270.cbp
index 7582bb0..ed00ddb 100644
--- a/lib3270.cbp
+++ b/lib3270.cbp
@@ -366,44 +366,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/core/host.c b/src/core/host.c
index ac6ddd8..7548142 100644
--- a/src/core/host.c
+++ b/src/core/host.c
@@ -52,7 +52,6 @@
#include "trace_dsc.h"
#include "utilc.h"
#include "xioc.h"
-#include "../ssl/crl.h"
#include "screenc.h"
#include
@@ -293,13 +292,10 @@ static void update_url(H3270 *hSession)
lib3270_write_event_trace(hSession,"Host URL was changed\nFrom: %s\nTo: %s\n",hSession->host.url,url);
lib3270_free(hSession->host.url);
hSession->host.url = url;
-
-#if defined(HAVE_LIBSSLx) && defined(SSL_ENABLE_CRL_CHECK)
- lib3270_crl_free(hSession);
-#endif // SSL_ENABLE_CRL_CHECK
-
hSession->cbk.update_url(hSession, hSession->host.url);
+ hSession->network.module->reset(hSession);
+
}
LIB3270_EXPORT const char * lib3270_get_associated_luname(const H3270 *hSession)
diff --git a/src/core/linux/connect.c b/src/core/linux/connect.c
index 84b1ef0..e2edde8 100644
--- a/src/core/linux/connect.c
+++ b/src/core/linux/connect.c
@@ -307,16 +307,6 @@
//
hSession->ever_3270 = False;
-#if defined(HAVE_LIBSSLx)
- if(hSession->ssl.enabled)
- {
- hSession->ssl.host = 1;
- if(ssl_init(hSession))
- return errno = ENOTCONN;
-
- }
-#endif // HAVE_LIBSSL
-
// set options for inline out-of-band data and keepalives
int optval = 1;
if(hSession->network.module->setsockopt(hSession, SOL_SOCKET, SO_OOBINLINE, &optval, sizeof(optval)) < 0)
diff --git a/src/core/properties/signed.c b/src/core/properties/signed.c
index 80f5fb2..aa658c7 100644
--- a/src/core/properties/signed.c
+++ b/src/core/properties/signed.c
@@ -49,48 +49,6 @@
return (int) lib3270_get_ssl_state(hSession);
}
- static int lib3270_set_ssl_minimum_protocol_version(H3270 *hSession, int value)
- {
-#ifdef HAVE_LIBSSLx
- FAIL_IF_ONLINE(hSession);
- hSession->ssl.protocol.min_version = value;
- return 0;
-#else
- return ENOTSUP;
-#endif // HAVE_LIBSSL
- }
-
- static int lib3270_set_ssl_maximum_protocol_version(H3270 *hSession, int value)
- {
-#ifdef HAVE_LIBSSLx
- FAIL_IF_ONLINE(hSession);
- hSession->ssl.protocol.max_version = value;
- return 0;
-#else
- return ENOTSUP;
-#endif // HAVE_LIBSSL
- }
-
- static int lib3270_get_ssl_minimum_protocol_version(const H3270 *hSession)
- {
-#ifdef HAVE_LIBSSLx
- return hSession->ssl.protocol.min_version;
-#else
- errno = ENOTSUP;
- return 0;
-#endif // HAVE_LIBSSL
- }
-
- static int lib3270_get_ssl_maximum_protocol_version(const H3270 *hSession)
- {
-#ifdef HAVE_LIBSSLx
- return hSession->ssl.protocol.max_version;
-#else
- errno = ENOTSUP;
- return 0;
-#endif // HAVE_LIBSSL
- }
-
const LIB3270_INT_PROPERTY * lib3270_get_int_properties_list(void)
{
@@ -117,22 +75,6 @@
.set = NULL // Set value.
},
- {
- .name = "ssl_min_protocol_version", // Property name.
- .description = N_( "ID of the minimum supported SSL protocol version" ), // Property description.
- .default_value = 0,
- .get = lib3270_get_ssl_minimum_protocol_version, // Get value.
- .set = lib3270_set_ssl_minimum_protocol_version // Set value.
- },
-
- {
- .name = "ssl_max_protocol_version", // Property name.
- .description = N_( "ID of the maximum supported SSL protocol version" ), // Property description.
- .default_value = 0,
- .get = lib3270_get_ssl_maximum_protocol_version, // Get value.
- .set = lib3270_set_ssl_maximum_protocol_version // Set value.
- },
-
{
.name = NULL,
.description = NULL,
diff --git a/src/core/session.c b/src/core/session.c
index 589592d..d90a5a7 100644
--- a/src/core/session.c
+++ b/src/core/session.c
@@ -42,7 +42,6 @@
#include "kybdc.h"
#include "3270ds.h"
#include "popupsc.h"
-#include "../ssl/crl.h"
#include
#include
#include
@@ -74,16 +73,6 @@ void lib3270_session_free(H3270 *h)
shutdown_toggles(h);
-#if defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBSSLx)
- if(h->ssl.crl.prefer)
- {
- free(h->ssl.crl.prefer);
- h->ssl.crl.prefer = NULL;
- }
-
- lib3270_crl_free(h);
-#endif // SSL_ENABLE_CRL_CHECK
-
// Release network module
if(h->network.module)
{
diff --git a/src/include/networking.h b/src/include/networking.h
index afe99e3..20f7263 100644
--- a/src/include/networking.h
+++ b/src/include/networking.h
@@ -166,6 +166,11 @@
/// @return String with the CRL certificate (release it with lib3270_free); NULL if not available.
char * (*getcrl)(const H3270 *hSession);
+ /// @brief Reset.
+ ///
+ /// Clear network module state (used when URL changes).
+ void (*reset)(H3270 *hSession);
+
} LIB3270_NET_MODULE;
/**
diff --git a/src/network_modules/default/main.c b/src/network_modules/default/main.c
index 44664f4..be21318 100644
--- a/src/network_modules/default/main.c
+++ b/src/network_modules/default/main.c
@@ -62,6 +62,9 @@
return 0;
}
+ static void unsecure_network_reset(H3270 GNUC_UNUSED(*hSession)) {
+ }
+
ssize_t unsecure_network_send(H3270 *hSession, const void *buffer, size_t length) {
ssize_t bytes = send(hSession->network.context->sock,buffer,length,0);
@@ -164,7 +167,8 @@ void lib3270_set_default_network_module(H3270 *hSession) {
.is_connected = unsecure_network_is_connected,
.getsockname = unsecure_network_getsockname,
.setsockopt = unsecure_network_setsockopt,
- .getsockopt = unsecure_network_getsockopt
+ .getsockopt = unsecure_network_getsockopt,
+ .reset = unsecure_network_reset
};
debug("%s",__FUNCTION__);
diff --git a/src/network_modules/openssl/main.c b/src/network_modules/openssl/main.c
index 7c4755f..32cc183 100644
--- a/src/network_modules/openssl/main.c
+++ b/src/network_modules/openssl/main.c
@@ -35,18 +35,21 @@
#include "private.h"
-static void openssl_network_finalize(H3270 *hSession) {
-
- debug("%s",__FUNCTION__);
+static void openssl_network_reset(H3270 *hSession) {
if(hSession->network.context) {
+ lib3270_openssl_crl_free(hSession->network.context);
+ }
+
+}
- // Cleanupp
- LIB3270_NET_CONTEXT *context = hSession->network.context;
+static void openssl_network_finalize(H3270 *hSession) {
- lib3270_openssl_crl_free(context);
+ debug("%s",__FUNCTION__);
- // Release network context.
+ openssl_network_reset(hSession);
+
+ if(hSession->network.context) {
lib3270_free(hSession->network.context);
hSession->network.context = NULL;
}
@@ -346,7 +349,8 @@ void lib3270_set_libssl_network_module(H3270 *hSession) {
.setsockopt = openssl_network_setsockopt,
.getsockopt = openssl_network_getsockopt,
.getcert = openssl_network_getcert,
- .getcrl = openssl_network_getcrl
+ .getcrl = openssl_network_getcrl,
+ .reset = openssl_network_reset
};
debug("%s",__FUNCTION__);
diff --git a/src/network_modules/state.c b/src/network_modules/state.c
index 3f9d911..fc6871a 100644
--- a/src/network_modules/state.c
+++ b/src/network_modules/state.c
@@ -50,15 +50,6 @@ LIB3270_EXPORT int lib3270_is_secure(const H3270 *hSession)
return lib3270_get_ssl_state(hSession) == LIB3270_SSL_SECURE;
}
-#if defined(HAVE_LIBSSLx)
-LIB3270_EXPORT long lib3270_get_SSL_verify_result(const H3270 *hSession)
-{
- if(hSession->ssl.con)
- return SSL_get_verify_result(hSession->ssl.con);
- return -1;
-}
-#endif // HAVE_LIBSSL
-
LIB3270_EXPORT LIB3270_SSL_STATE lib3270_get_ssl_state(const H3270 *hSession)
{
return hSession->ssl.state;
diff --git a/src/ssl/crl.c b/src/ssl/crl.c
deleted file mode 100644
index f5e7aec..0000000
--- a/src/ssl/crl.c
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
-#include
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "crl.h"
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-#if defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBSSL)
-
-void lib3270_crl_free(H3270 *hSession)
-{
- if(hSession->ssl.crl.cert)
- {
- X509_CRL_free(hSession->ssl.crl.cert);
- hSession->ssl.crl.cert = NULL;
- }
-
- if(hSession->ssl.crl.url)
- {
- free(hSession->ssl.crl.url);
- hSession->ssl.crl.url = NULL;
- }
-
-}
-
-void lib3270_crl_free_if_expired(H3270 *hSession)
-{
- if(!hSession->ssl.crl.cert)
- return;
-
- // https://stackoverflow.com/questions/23407376/testing-x509-certificate-expiry-date-with-c
- // X509_CRL_get_nextUpdate is deprecated in openssl 1.1.0
- #if OPENSSL_VERSION_NUMBER < 0x10100000L
- const ASN1_TIME * next_update = X509_CRL_get_nextUpdate(hSession->ssl.crl.cert);
- #else
- const ASN1_TIME * next_update = X509_CRL_get0_nextUpdate(hSession->ssl.crl.cert);
- #endif
-
- if(X509_cmp_current_time(next_update) == 1)
- {
- int day, sec;
- if(ASN1_TIME_diff(&day, &sec, NULL, next_update))
- {
- trace_ssl(hSession,"CRL is valid for %d day(s) and %d second(s)\n",day,sec);
- return;
- }
-
- trace_ssl(hSession,"Can't get CRL next update, discarding it\n");
-
- }
- else
- {
- trace_ssl(hSession,"CRL is no longer valid\n");
- }
-
- // Certificate is no longer valid, release it.
- X509_CRL_free(hSession->ssl.crl.cert);
- hSession->ssl.crl.cert = NULL;
-
-}
-
-int lib3270_crl_new_from_url(H3270 *hSession, void *ssl_error, const char *url)
-{
- if(!(url && *url))
- return -1;
-
- lib3270_crl_free(hSession); // Just in case!
-
- //
- // Get the new CRL
- //
- // https://stackoverflow.com/questions/10510850/how-to-verify-the-certificate-for-the-ongoing-ssl-session
- //
- trace_ssl(hSession,"Getting CRL from %s\n",url);
-
- hSession->ssl.crl.cert = lib3270_download_crl(hSession,(SSL_ERROR_MESSAGE *) ssl_error, url);
-
- if(hSession->ssl.crl.cert)
- {
- // Got CRL!
-
- // Update URL
- if(hSession->ssl.crl.url)
- lib3270_free(hSession->ssl.crl.url);
-
- hSession->ssl.crl.url = lib3270_strdup(url);
-
- // Add it to ssl store
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- lib3270_autoptr(char) text = lib3270_get_ssl_crl_text(hSession);
-
- if(text)
- trace_ssl(hSession,"\n%s\n",text);
-
- }
-
- // Add CRL in the store.
- X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
- if(X509_STORE_add_crl(store, hSession->ssl.crl.cert))
- {
- trace_ssl(hSession,"CRL was added to context cert store\n");
- }
- else
- {
- trace_ssl(hSession,"CRL was not added to context cert store\n");
- }
-
- return 0;
- }
-
- trace_ssl(hSession,"Can't get CRL using %s\n",url);
-
- return -1;
-
-}
-
-/// @brief Load CRL from X509 certificate.
-int lib3270_crl_new_from_x509(H3270 *hSession, void *ssl_error, X509 *cert)
-{
- // References:
- //
- // http://www.zedwood.com/article/cpp-check-crl-for-revocation
- //
- lib3270_autoptr(CRL_DIST_POINTS) dist_points = (CRL_DIST_POINTS *) X509_get_ext_d2i(cert, NID_crl_distribution_points, NULL, NULL);
-
- if(!dist_points)
- {
- static const LIB3270_POPUP popup = {
- .name = "SSL-NoDistPoints",
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_("Can't verify"),
- .body = N_( "The host certificate doesn't have CRL distribution points" )
- };
-
- ((SSL_ERROR_MESSAGE *) ssl_error)->popup = &popup;
- return EACCES;
- }
-
- if(lib3270_crl_new_from_dist_points(hSession, ssl_error, dist_points))
- return EACCES;
-
- return 0;
-}
-
-int lib3270_crl_new_from_dist_points(H3270 *hSession, void *ssl_error, CRL_DIST_POINTS * dist_points)
-{
- //
- // Reference:
- //
- // https://nougat.cablelabs.com/DLNA-RUI/openssl/commit/57912ed329f870b237f2fd9f2de8dec3477d1729
- //
- size_t ix;
- int i;
-
- lib3270_autoptr(LIB3270_STRING_ARRAY) uris = lib3270_string_array_new();
-
- for(ix = 0; ix < (size_t) sk_DIST_POINT_num(dist_points); ix++) {
-
- DIST_POINT *dp = sk_DIST_POINT_value(dist_points, ix);
-
- if(!dp->distpoint || dp->distpoint->type != 0)
- continue;
-
- GENERAL_NAMES *gens = dp->distpoint->name.fullname;
-
- for (i = 0; i < sk_GENERAL_NAME_num(gens); i++)
- {
- int gtype;
- GENERAL_NAME *gen = sk_GENERAL_NAME_value(gens, i);
- ASN1_STRING *uri = GENERAL_NAME_get0_value(gen, >ype);
-
- if(uri && gtype == GEN_URI)
- {
- int length = ASN1_STRING_length(uri);
-
-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L) // OpenSSL 1.1.0+
- const unsigned char * data = ASN1_STRING_get0_data(uri);
-#else
- const unsigned char * data = ASN1_STRING_data(uri);
-#endif // OpenSSL 1.1.0+
-
- if(data && length > 0)
- lib3270_string_array_append_with_length(uris,(char *) data, (size_t) length);
-
- }
-
- }
-
- }
-
-#ifdef DEBUG
- {
- for(ix = 0; ix < uris->length; ix++)
- {
- debug("%u: %s", (unsigned int) ix, uris->str[ix]);
- }
- }
-#endif // DEBUG
-
- if(hSession->ssl.crl.url)
- {
- // Check if the current URL is still valid.
- for(ix = 0; ix < uris->length; ix++)
- {
- if(!strcmp(hSession->ssl.crl.url,uris->str[ix]))
- {
- trace_ssl(hSession,"Keeping CRL from %s\n",hSession->ssl.crl.url);
- return 0;
- }
- }
-
- trace_ssl(hSession,"Discarding invalid CRL from %s\n",hSession->ssl.crl.url);
-
- // The URL is invalid or not to this cert, remove it!
- lib3270_free(hSession->ssl.crl.url);
- hSession->ssl.crl.url = NULL;
- }
-
- //
- // Downloading CRLs
- //
- if(hSession->ssl.crl.download)
- {
- if(hSession->ssl.crl.prefer && *hSession->ssl.crl.prefer)
- {
- size_t length = strlen(hSession->ssl.crl.prefer);
-
- for(ix = 0; ix < uris->length; ix++)
- {
- if(!strncmp(uris->str[ix],hSession->ssl.crl.prefer,length))
- {
- trace_ssl(hSession,"Trying preferred URL %s\n",uris->str[ix]);
- if(lib3270_crl_new_from_url(hSession, ssl_error, uris->str[ix]) == 0)
- return 0;
- }
-
- }
-
- }
-
- // Can't load, try all of them.
- for(ix = 0; ix < uris->length; ix++)
- {
- trace_ssl(hSession,"Trying CRL from %s\n",uris->str[ix]);
- if(lib3270_crl_new_from_url(hSession, ssl_error, uris->str[ix]) == 0)
- return 0;
- }
-
- return -1;
- }
-
- return 0;
-
-}
-
-#endif // SSL_ENABLE_CRL_CHECK && HAVE_LIBSSL
diff --git a/src/ssl/crl.h b/src/ssl/crl.h
deleted file mode 100644
index 94c352d..0000000
--- a/src/ssl/crl.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral ', conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como private.h e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
- *
- */
-
-#ifdef WIN32
- #include
- #include
-#endif // WIN32
-
-#include /* autoconf settings */
-#include /* lib3270 API calls and defs */
-
-#if defined(HAVE_LIBSSLx)
-
- #include
- #include
-
- /**
- * @brief X509 auto-cleanup.
- */
- static inline void lib3270_autoptr_cleanup_X509(X509 **ptr)
- {
- if(*ptr)
- X509_free(*ptr);
- }
-
- /**
- * @brief Dist points auto-cleanup.
- */
- static inline void lib3270_autoptr_cleanup_CRL_DIST_POINTS(CRL_DIST_POINTS **ptr)
- {
- if(*ptr)
- CRL_DIST_POINTS_free(*ptr);
- }
-
-
-#endif // HAVE_LIBSSL
-
-#if defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBSSLx)
-
- /// @brief Unconditional release of the session CRL.
- LIB3270_INTERNAL void lib3270_crl_free(H3270 *hSession);
-
- /// @brief Load CRL from URL.
- LIB3270_INTERNAL int lib3270_crl_new_from_url(H3270 *hSession, void *ssl_error, const char *url);
-
- /// @brief Load CRL from X509 certificate.
- LIB3270_INTERNAL int lib3270_crl_new_from_x509(H3270 *hSession, void *ssl_error, X509 *cert);
-
- /// @brief Load CRL from distribution points.
- LIB3270_INTERNAL int lib3270_crl_new_from_dist_points(H3270 *hSession, void *ssl_error, CRL_DIST_POINTS * dist_points);
-
- LIB3270_INTERNAL X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *url);
-
-
-#endif // SSL_ENABLE_CRL_CHECK && HAVE_LIBSSL
-
-
-
diff --git a/src/ssl/linux/getcrl.c b/src/ssl/linux/getcrl.c
deleted file mode 100644
index 98f287c..0000000
--- a/src/ssl/linux/getcrl.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include "private.h"
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_FILE(FILE **file)
-{
- if(*file)
- fclose(*file);
-}
-
-X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- if(!(consturl && *consturl))
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .name = "SSL-INVCRLURL",
- .summary = N_( "Can't open CRL File" ),
- .body = N_("The URL for the CRL is undefined or empty")
- };
-
- message->code = hSession->ssl.error = 0;
- message->popup = &popup;
- errno = ENOENT;
- return NULL;
- }
-
- if(strncasecmp(consturl,"file://",7) == 0)
- {
- lib3270_autoptr(FILE) hCRL = fopen(consturl+7,"r");
-
- if(!hCRL)
- {
- // Can't open CRL File.
- int err = errno;
-
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .name = "SSL-CRLOPEN",
- .summary = N_( "Can't open CRL File" )
- };
-
- message->code = hSession->ssl.error = 0;
- message->popup = &popup;
-
- trace_ssl(hSession,"Can't open %s: %s\n",consturl,strerror(err));
-
- return NULL;
-
- }
-
- trace_ssl(hSession,"Loading CRL from %s\n",consturl+7);
- if(d2i_X509_CRL_fp(hCRL, &x509_crl))
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .name = "SSL-CRLDECODE",
- .summary = N_( "Can't decode CRL" )
- };
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, popup.summary);
- return NULL;
- }
-
- }
-#ifdef HAVE_LDAP
- else if(strncasecmp(consturl,"ldap://",7) == 0 && strlen(consturl) > 8)
- {
- return get_crl_using_ldap(hSession, message, consturl);
-
- }
-#endif // HAVE_LDAP
- else
- {
-#ifdef HAVE_LIBCURL
-
- return get_crl_using_url(hSession, message, consturl);
-
-#else
- // Can't get CRL.
-
- message->error = hSession->ssl.error = 0;
-
- if(!(message->text && message->description))
- message->title = _( "Security error" );
-
- if(!message->text)
- message->text = _( "Unexpected or invalid CRL URL" );
-
- if(!message->description)
- message->description = _("The URL scheme is unknown");
-
- trace_ssl(hSession,"%s: The URL scheme is unknown",consturl);
-
- errno = EINVAL;
- return NULL;
-#endif // HAVE_LIBCURL
- }
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK
diff --git a/src/ssl/linux/ldap.c b/src/ssl/linux/ldap.c
deleted file mode 100644
index 2762c89..0000000
--- a/src/ssl/linux/ldap.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "utilc.h"
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LDAP)
-
-#include
-#include
-#include
-#include
-
-#define LDAP_DEPRECATED 1
-#include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_LDAPMessage(LDAPMessage **message)
-{
- debug("%s(%p)",__FUNCTION__,*message);
- if(message)
- ldap_msgfree(*message);
- *message = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_LDAP(LDAP **ld)
-{
- debug("%s(%p)",__FUNCTION__,*ld);
- if(*ld)
- ldap_unbind_ext(*ld, NULL, NULL);
- *ld = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_BerElement(BerElement **ber)
-{
- debug("%s(%p)",__FUNCTION__,*ber);
- if(*ber)
- ber_free(*ber, 0);
- *ber = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_LDAPPTR(char **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- ldap_memfree(*ptr);
- *ptr = NULL;
-}
-
-LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- int rc;
- lib3270_autoptr(char) url = lib3270_unescape(consturl);
- char * base = strchr(url+7,'/');
- char * attrs[] = { NULL, NULL };
-
- if(!base)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "No DN of the entry at which to start the search on the URL" );
- message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" );
- errno = EINVAL;
- return NULL;
- }
-
- *(base++) = 0;
- attrs[0] = strchr(base,'?');
-
- if(!base)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "No LDAP attribute on the URL" );
- message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" );
- errno = EINVAL;
- return NULL;
- }
-
- *(attrs[0]++) = 0;
-
- debug("host: \"%s\"",url);
- debug("Base: \"%s\"",base);
- debug("Attr: \"%s\"",attrs[0]);
-
- // Do LDAP Query
- LDAP __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAP))) *ld = NULL;
- BerElement __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_BerElement))) * ber = NULL;
-
- rc = ldap_initialize(&ld, url);
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't initialize LDAP" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- unsigned long version = LDAP_VERSION3;
- rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,(void *) &version);
- if(rc != LDAP_SUCCESS) {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't set LDAP protocol version" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- rc = ldap_simple_bind_s(ld, "", "");
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't bind to LDAP server" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- lib3270_autoptr(LDAPMessage) results = NULL;
- rc = ldap_search_ext_s(
- ld, // Specifies the LDAP pointer returned by a previous call to ldap_init(), ldap_ssl_init(), or ldap_open().
- base, // Specifies the DN of the entry at which to start the search.
- LDAP_SCOPE_BASE, // Specifies the scope of the search.
- NULL, // Specifies a string representation of the filter to apply in the search.
- (char **) &attrs, // Specifies a null-terminated array of character string attribute types to return from entries that match filter.
- 0, // Should be set to 1 to request attribute types only. Set to 0 to request both attributes types and attribute values.
- NULL,
- NULL,
- NULL,
- 0,
- &results
- );
-
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't search LDAP server" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- char __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAPPTR))) *attr = ldap_first_attribute(ld, results, &ber);
- if(!attr)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't get LDAP attribute" );
- message->description = _("Search did not produce any attributes.");
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- errno = ENOENT;
- return NULL;
- }
-
- struct berval ** value = ldap_get_values_len(ld, results, attr);
- if(!value)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't get LDAP attribute" );
- message->description = _("Search did not produce any values.");
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- errno = ENOENT;
- return NULL;
- }
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- lib3270_trace_data(
- hSession,
- "CRL Data received from LDAP server",
- (const unsigned char *) value[0]->bv_val,
- value[0]->bv_len
- );
- }
-
- // Precisa salvar uma cópia porque d2i_X509_CRL modifica o ponteiro.
- const unsigned char *crl_data = (const unsigned char *) value[0]->bv_val;
-
- if(!d2i_X509_CRL(&x509_crl, &crl_data, value[0]->bv_len))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list" );
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->text);
- ldap_value_free_len(value);
- return NULL;
- }
-
- ldap_value_free_len(value);
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK && HAVE_LDAP
diff --git a/src/ssl/linux/private.h b/src/ssl/linux/private.h
deleted file mode 100644
index ea8164d..0000000
--- a/src/ssl/linux/private.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral ', conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como private.h e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
- *
- */
-
-#ifndef LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
-
- #define LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
-
- #include
-
- #include
- #include
- #include
- #include
-
- #include
- #include
- #include
- #include
- #include
- #include
-
- #if defined(HAVE_LIBSSL) && defined(HAVE_LDAP)
-
- /// @brief Use libldap to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LDAP
-
- #if defined (HAVE_LIBSSLx) && defined(HAVE_LIBCURL)
-
- /// @brief Use libcurl to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_url(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LIBCURL
-
-
-#endif // !LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
diff --git a/src/ssl/linux/url.c b/src/ssl/linux/url.c
deleted file mode 100644
index 44809de..0000000
--- a/src/ssl/linux/url.c
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBCURL)
-
-#include "private.h"
-#include
-#include
-
-#define CRL_DATA_LENGTH 2048
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_BIO(BIO **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- BIO_free_all(*ptr);
- *ptr = NULL;
-}
-
-LIB3270_INTERNAL X509_CRL * get_crl_using_url(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- size_t szText = 0;
- const char * error_message = NULL;
- lib3270_autoptr(char) httpText = lib3270_get_from_url(hSession, consturl, &szText, &error_message);
-
- if(!httpText)
- {
- LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .name = "SSL-CantGetCRL",
- .summary = N_( "Error getting certificate revocation list" ),
- .body = error_message
- };
- message->popup = &popup;
- return NULL;
- }
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- lib3270_trace_data(hSession,"CRL Data",(const unsigned char *) httpText, (unsigned int) szText);
-
- if(strncasecmp(consturl,"ldap://",7) == 0)
- {
- // It's an LDAP query, assumes a base64 data.
- char * data = strstr((char *) httpText,":: ");
- if(!data)
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_( "Got a bad formatted certificate revocation list from LDAP server" )
- };
-
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- lib3270_write_log(hSession,"ssl","%s: invalid format:\n%s\n", consturl, httpText);
- errno = EINVAL;
- return NULL;
- }
- data += 3;
-
- lib3270_autoptr(BIO) bio = BIO_new_mem_buf(httpText,-1);
-
- BIO * b64 = BIO_new(BIO_f_base64());
- bio = BIO_push(b64, bio);
-
- BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
-
- if(!d2i_X509_CRL_bio(bio, &x509_crl))
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_( "Can't decode certificate revocation list got from LDAP server" )
- };
-
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
-
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, popup.summary);
- errno = EINVAL;
- return NULL;
- }
-
- }
- else
- {
- // CRL File, convert it
- // Copy the pointer because d2i_X509_CRL changes the value!!!
- const unsigned char *crl_data = (const unsigned char *) httpText;
-
- if(!d2i_X509_CRL(&x509_crl, &crl_data, szText))
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_( "Can't decode certificate revocation list" )
- };
-
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, popup.summary);
- return NULL;
- }
-
- }
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK && HAVE_LIBCURL
diff --git a/src/ssl/macos/getcrl.c b/src/ssl/macos/getcrl.c
deleted file mode 100644
index 99ec938..0000000
--- a/src/ssl/macos/getcrl.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include "private.h"
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_FILE(FILE **file)
-{
- if(*file)
- fclose(*file);
-}
-
-X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- if(!(consturl && *consturl))
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't open CRL File" );
- message->description = _("The URL for the CRL is undefined or empty");
- errno = ENOENT;
- return NULL;
- }
-
- if(strncasecmp(consturl,"file://",7) == 0)
- {
- lib3270_autoptr(FILE) hCRL = fopen(consturl+7,"r");
-
- if(!hCRL)
- {
- // Can't open CRL File.
- int err = errno;
-
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't open CRL File" );
- message->description = strerror(err);
- trace_ssl(hSession,"Can't open %s: %s\n",consturl,message->description);
- return NULL;
-
- }
-
- trace_ssl(hSession,"Loading CRL from %s\n",consturl+7);
- if(d2i_X509_CRL_fp(hCRL, &x509_crl))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode CRL" );
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text);
- return NULL;
- }
-
-
-
- }
-#ifdef HAVE_LDAP
- else if(strncasecmp(consturl,"ldap://",7) == 0 && strlen(consturl) > 8)
- {
- return get_crl_using_ldap(hSession, message, consturl);
-
- }
-#endif // HAVE_LDAP
- else
- {
-#ifdef HAVE_LIBCURL
-
- return get_crl_using_url(hSession, message, consturl);
-
-#else
- // Can't get CRL.
-
- message->error = hSession->ssl.error = 0;
-
- if(!(message->text && message->description))
- message->title = _( "Security error" );
-
- if(!message->text)
- message->text = _( "Unexpected or invalid CRL URL" );
-
- if(!message->description)
- message->description = _("The URL scheme is unknown");
-
- trace_ssl(hSession,"%s: The URL scheme is unknown",consturl);
-
- errno = EINVAL;
- return NULL;
-#endif // HAVE_LIBCURL
- }
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK
diff --git a/src/ssl/macos/init.c b/src/ssl/macos/init.c
deleted file mode 100644
index 80b9181..0000000
--- a/src/ssl/macos/init.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-/**
- * @brief OpenSSL initialization for linux.
- *
- */
-
-#include
-
-#if defined(HAVE_LIBSSL)
-
-#include
-#include
-#include
-
-#ifndef SSL_ST_OK
- #define SSL_ST_OK 3
-#endif // !SSL_ST_OK
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include "trace_dsc.h"
-
-#ifdef SSL_ENABLE_CRL_CHECK
- #include
-#endif // SSL_ENABLE_CRL_CHECK
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-/**
- * @brief Initialize openssl library.
- *
- * @return 0 if ok, non zero if fails.
- *
- */
-int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message)
-{
- debug("%s ssl_ctx=%p",__FUNCTION__,ssl_ctx);
-
- if(ssl_ctx)
- return 0;
-
- trace_ssl(hSession,"Initializing SSL context.\n");
-
- SSL_load_error_strings();
- SSL_library_init();
-
- ssl_ctx = SSL_CTX_new(SSLv23_method());
- if(ssl_ctx == NULL)
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Cant initialize the SSL context." );
- return -1;
- }
-
- SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL);
- SSL_CTX_set_info_callback(ssl_ctx, ssl_info_callback);
-
- SSL_CTX_set_default_verify_paths(ssl_ctx);
-
- ssl_3270_ex_index = SSL_get_ex_new_index(0,NULL,NULL,NULL,NULL);
-
-#ifdef SSL_ENABLE_CRL_CHECK
-
- // Enable CRL check
- X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx);
- X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
- X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
- X509_STORE_set1_param(store, param);
- X509_VERIFY_PARAM_free(param);
-
- trace_ssl(hSession,"CRL CHECK was enabled\n");
-
-#endif // SSL_ENABLE_CRL_CHECK
-
- return 0;
-
-}
-
-#endif // HAVE_LIBSSL
diff --git a/src/ssl/macos/ldap.c b/src/ssl/macos/ldap.c
deleted file mode 100644
index 2762c89..0000000
--- a/src/ssl/macos/ldap.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-#include
-#include
-#include
-#include
-
-#include "utilc.h"
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LDAP)
-
-#include
-#include
-#include
-#include
-
-#define LDAP_DEPRECATED 1
-#include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_LDAPMessage(LDAPMessage **message)
-{
- debug("%s(%p)",__FUNCTION__,*message);
- if(message)
- ldap_msgfree(*message);
- *message = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_LDAP(LDAP **ld)
-{
- debug("%s(%p)",__FUNCTION__,*ld);
- if(*ld)
- ldap_unbind_ext(*ld, NULL, NULL);
- *ld = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_BerElement(BerElement **ber)
-{
- debug("%s(%p)",__FUNCTION__,*ber);
- if(*ber)
- ber_free(*ber, 0);
- *ber = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_LDAPPTR(char **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- ldap_memfree(*ptr);
- *ptr = NULL;
-}
-
-LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- int rc;
- lib3270_autoptr(char) url = lib3270_unescape(consturl);
- char * base = strchr(url+7,'/');
- char * attrs[] = { NULL, NULL };
-
- if(!base)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "No DN of the entry at which to start the search on the URL" );
- message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" );
- errno = EINVAL;
- return NULL;
- }
-
- *(base++) = 0;
- attrs[0] = strchr(base,'?');
-
- if(!base)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "No LDAP attribute on the URL" );
- message->description = _( "The URL argument should be in the format ldap://[HOST]/[DN]?attribute" );
- errno = EINVAL;
- return NULL;
- }
-
- *(attrs[0]++) = 0;
-
- debug("host: \"%s\"",url);
- debug("Base: \"%s\"",base);
- debug("Attr: \"%s\"",attrs[0]);
-
- // Do LDAP Query
- LDAP __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAP))) *ld = NULL;
- BerElement __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_BerElement))) * ber = NULL;
-
- rc = ldap_initialize(&ld, url);
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't initialize LDAP" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- unsigned long version = LDAP_VERSION3;
- rc = ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION,(void *) &version);
- if(rc != LDAP_SUCCESS) {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't set LDAP protocol version" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- rc = ldap_simple_bind_s(ld, "", "");
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't bind to LDAP server" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- lib3270_autoptr(LDAPMessage) results = NULL;
- rc = ldap_search_ext_s(
- ld, // Specifies the LDAP pointer returned by a previous call to ldap_init(), ldap_ssl_init(), or ldap_open().
- base, // Specifies the DN of the entry at which to start the search.
- LDAP_SCOPE_BASE, // Specifies the scope of the search.
- NULL, // Specifies a string representation of the filter to apply in the search.
- (char **) &attrs, // Specifies a null-terminated array of character string attribute types to return from entries that match filter.
- 0, // Should be set to 1 to request attribute types only. Set to 0 to request both attributes types and attribute values.
- NULL,
- NULL,
- NULL,
- 0,
- &results
- );
-
- if(rc != LDAP_SUCCESS)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't search LDAP server" );
- message->description = ldap_err2string(rc);
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- return NULL;
- }
-
- char __attribute__ ((__cleanup__(lib3270_autoptr_cleanup_LDAPPTR))) *attr = ldap_first_attribute(ld, results, &ber);
- if(!attr)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't get LDAP attribute" );
- message->description = _("Search did not produce any attributes.");
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- errno = ENOENT;
- return NULL;
- }
-
- struct berval ** value = ldap_get_values_len(ld, results, attr);
- if(!value)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't get LDAP attribute" );
- message->description = _("Search did not produce any values.");
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->description);
- errno = ENOENT;
- return NULL;
- }
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- lib3270_trace_data(
- hSession,
- "CRL Data received from LDAP server",
- (const unsigned char *) value[0]->bv_val,
- value[0]->bv_len
- );
- }
-
- // Precisa salvar uma cópia porque d2i_X509_CRL modifica o ponteiro.
- const unsigned char *crl_data = (const unsigned char *) value[0]->bv_val;
-
- if(!d2i_X509_CRL(&x509_crl, &crl_data, value[0]->bv_len))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list" );
- lib3270_write_log(hSession,"ssl","%s: %s",url, message->text);
- ldap_value_free_len(value);
- return NULL;
- }
-
- ldap_value_free_len(value);
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK && HAVE_LDAP
diff --git a/src/ssl/macos/private.h b/src/ssl/macos/private.h
deleted file mode 100644
index e3096e7..0000000
--- a/src/ssl/macos/private.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral ', conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como private.h e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
- *
- */
-
-#ifndef LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
-
- #define LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
-
- #include
-
- #include
- #include
- #include
- #include
-
- #include
- #include
- #include
- #include
- #include
- #include
-
- #ifdef HAVE_LDAP
-
- /// @brief Use libldap to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LDAP
-
- #ifdef HAVE_LIBCURL
-
- /// @brief Use libcurl to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_url(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LIBCURL
-
-
-#endif // !LIB3270_LINUX_SSL_PRIVATE_H_INCLUDED
diff --git a/src/ssl/macos/url.c b/src/ssl/macos/url.c
deleted file mode 100644
index 18bfe54..0000000
--- a/src/ssl/macos/url.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBCURL)
-
-#include "private.h"
-#include
-#include
-
-#define CRL_DATA_LENGTH 2048
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_BIO(BIO **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- BIO_free_all(*ptr);
- *ptr = NULL;
-}
-
-LIB3270_INTERNAL X509_CRL * get_crl_using_url(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- size_t szText = 0;
- lib3270_autoptr(char) httpText = lib3270_get_from_url(hSession, consturl, &szText, &message->description);
-
- if(!httpText)
- {
- message->title = _( "Security error" );
- message->text = _( "Error getting certificate revocation list" );
- return NULL;
- }
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- lib3270_trace_data(hSession,"CRL Data",(const unsigned char *) httpText, (unsigned int) szText);
-
- if(strncasecmp(consturl,"ldap://",7) == 0)
- {
- // It's an LDAP query, assumes a base64 data.
- char * data = strstr((char *) httpText,":: ");
- if(!data)
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Got a bad formatted certificate revocation list from LDAP server" );
- lib3270_write_log(hSession,"ssl","%s: invalid format:\n%s\n", consturl, httpText);
- errno = EINVAL;
- return NULL;
- }
- data += 3;
-
- lib3270_autoptr(BIO) bio = BIO_new_mem_buf(httpText,-1);
-
- BIO * b64 = BIO_new(BIO_f_base64());
- bio = BIO_push(b64, bio);
-
- BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
-
- if(!d2i_X509_CRL_bio(bio, &x509_crl))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list got from LDAP server" );
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text);
- errno = EINVAL;
- return NULL;
- }
-
- }
- else
- {
- // CRL File, convert it
- // Copy the pointer because d2i_X509_CRL changes the value!!!
- const unsigned char *crl_data = (const unsigned char *) httpText;
-
- if(!d2i_X509_CRL(&x509_crl, &crl_data, szText))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list" );
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text);
- return NULL;
- }
-
- }
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK && HAVE_LIBCURL
diff --git a/src/ssl/negotiate.c b/src/ssl/negotiate.c
deleted file mode 100644
index 246551b..0000000
--- a/src/ssl/negotiate.c
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- *
- */
-
-
-#include
-#include
-
-#if defined(HAVE_LIBSSL)
-
- #include
- #include
- #include
- #include
-
- #ifndef SSL_ST_OK
- #define SSL_ST_OK 3
- #endif // !SSL_ST_OK
-
- #include "crl.h"
-
-#endif
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include "hostc.h" // host_disconnect
-#include "trace_dsc.h"
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-#if defined(HAVE_LIBSSLx)
-
- /**
- * @brief Index of h3270 handle in SSL session.
- *
- */
- int ssl_3270_ex_index = -1;
-
-/**
- * @brief Global SSL_CTX object as framework to establish TLS/SSL or DTLS enabled connections.
- *
- */
- SSL_CTX * ssl_ctx = NULL;
-
-/**
- * @brief Initialize openssl session.
- *
- * @param hSession lib3270 session handle.
- *
- * @return 0 if ok, non zero if fails.
- *
- */
-static int background_ssl_init(H3270 *hSession, void *message)
-{
- set_ssl_state(hSession,LIB3270_SSL_UNDEFINED);
- hSession->ssl.error = 0;
- hSession->ssl.host = False;
-
- if(ssl_ctx_init(hSession, (SSL_ERROR_MESSAGE *) message)) {
- debug("%s has failed","ssl_ctx_init");
- set_ssl_state(hSession,LIB3270_SSL_UNDEFINED);
- hSession->ssl.host = False;
- return -1;
- }
-
- if(hSession->ssl.con)
- SSL_free(hSession->ssl.con);
-
- hSession->ssl.con = SSL_new(ssl_ctx);
- if(hSession->ssl.con == NULL)
- {
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_( "Cant create a new SSL structure for current connection." )
- };
-
- ((SSL_ERROR_MESSAGE *) message)->code = hSession->ssl.error = ERR_get_error();
- ((SSL_ERROR_MESSAGE *) message)->popup = &popup;
- return -1;
- }
-
- SSL_set_ex_data(hSession->ssl.con,ssl_3270_ex_index,(char *) hSession);
-// SSL_set_verify(session->ssl_con, SSL_VERIFY_FAIL_IF_NO_PEER_CERT, NULL);
- SSL_set_verify(hSession->ssl.con, 0, NULL);
-
- return 0;
-}
-
-#if defined(SSL_ENABLE_CRL_CHECK)
-int x509_store_ctx_error_callback(int ok, X509_STORE_CTX GNUC_UNUSED(*ctx))
-{
- debug("%s(%d)",__FUNCTION__,ok);
-
-/*
- 55 {
- 56 if (!ok) {
- 57 Category::getInstance("OpenSSL").error(
- 58 "path validation failure at depth(%d): %s",
- 59 X509_STORE_CTX_get_error_depth(ctx),
- 60 X509_verify_cert_error_string(X509_STORE_CTX_get_error(ctx))
- 61 );
- 62 }
- 63 return ok;
- 64 }
-*/
- return ok;
-}
-#endif // SSL_ENABLE_CRL_CHECK
-
-static const struct ssl_protocol {
- int id;
- const char * description;
-} ssl_protocols[] = {
-
- {
- .id = SSL3_VERSION,
- .description = SSL_TXT_SSLV3
- },
- {
- .id = TLS1_VERSION,
- .description = SSL_TXT_TLSV1
- },
- {
- .id = TLS1_1_VERSION,
- .description = SSL_TXT_TLSV1_1
- },
- {
- .id = TLS1_2_VERSION,
- .description = SSL_TXT_TLSV1_2
- },
-#ifdef DTLS1_VERSION
- {
- .id = DTLS1_VERSION,
- .description = "DTLSv1"
- },
-#endif // DTLS1_VERSION
-#ifdef DTLS1_2_VERSION
- {
- .id = DTLS1_2_VERSION,
- .description = "DTLSv2"
- },
-#endif // DTLS1_2_VERSION
-
-};
-
-static const struct ssl_protocol * get_protocol_from_id(int id) {
-
- if(id < 1)
- return NULL;
-
- id--;
-
- if( ((size_t) id) > (sizeof(ssl_protocols)/sizeof(ssl_protocols[0])))
- return NULL;
-
- return ssl_protocols + id;
-
-}
-
-static int background_ssl_negotiation(H3270 *hSession, void *message)
-{
- int rv;
-
- trace("%s",__FUNCTION__);
-
- /* Initialize the SSL library. */
- if(background_ssl_init(hSession,message))
- {
- return -1;
- }
-
- /* Set up the TLS/SSL connection. */
- const struct ssl_protocol * protocol;
-
- if( (protocol = get_protocol_from_id(hSession->ssl.protocol.min_version)) != NULL )
- {
-#if (OPENSSL_VERSION_NUMBER >= 0x1010009fL)
- if(SSL_set_min_proto_version(hSession->ssl.con,protocol->id) == 1)
- {
- trace_ssl(hSession,"Minimum protocol version set to %s\n",protocol->description);
- }
- else
- {
- lib3270_write_log(hSession,"ssl","Can't set minimum protocol version to %s",protocol->description);
- }
-#else
- trace_ssl(hSession,"Can't set minimum protocol version to %s\n",protocol->description);
-#endif // OPENSSL_VERSION_NUMBER
- }
-
- if( (protocol = get_protocol_from_id(hSession->ssl.protocol.max_version)) != NULL )
- {
-#if (OPENSSL_VERSION_NUMBER >= 0x1010009fL)
- if(SSL_set_max_proto_version(hSession->ssl.con,protocol->id) == 1)
- {
- trace_ssl(hSession,"Maximum protocol version set to %s\n",protocol->description);
- }
- else
- {
- lib3270_write_log(hSession,"ssl","Can't set maximum protocol version to %s",protocol->description);
- }
-#else
- trace_ssl(hSession,"Can't set maximum protocol version to %s\n",protocol->description);
-#endif // OPENSSL_VERSION_NUMBER
- }
-
- if(SSL_set_fd(hSession->ssl.con, hSession->connection.sock) != 1)
- {
- trace_ssl(hSession,"%s","SSL_set_fd failed!\n");
-
- static const LIB3270_POPUP popup = {
- .summary = N_( "SSL negotiation failed" ),
- .body = N_( "Cant set the file descriptor for the input/output facility for the TLS/SSL (encrypted) side of ssl." )
- };
-
- ((SSL_ERROR_MESSAGE *) message)->popup = &popup;
-
- return -1;
- }
-
-#ifdef SSL_CRL_URL
-
- // Load CRL from pre-defined URL
- if(!hSession->ssl.crl.cert)
- {
- if(lib3270_crl_new_from_url(hSession, message, SSL_CRL_URL))
- return EACCES;
- }
-
-#endif // SSL_CRL_URL
-
- trace_ssl(hSession, "%s","Running SSL_connect\n");
- rv = SSL_connect(hSession->ssl.con);
- trace_ssl(hSession, "SSL_connect exits with rc=%d\n",rv);
-
- if (rv != 1)
- {
- ((SSL_ERROR_MESSAGE *) message)->code = SSL_get_error(hSession->ssl.con,rv);
- if(((SSL_ERROR_MESSAGE *) message)->code == SSL_ERROR_SYSCALL && hSession->ssl.error)
- ((SSL_ERROR_MESSAGE *) message)->code = hSession->ssl.error;
-
- const char * msg = ERR_lib_error_string(((SSL_ERROR_MESSAGE *) message)->code);
-
- trace_ssl(hSession,"SSL_connect failed: %s %s\n",msg,ERR_reason_error_string(hSession->ssl.error));
-
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_ERROR,
- .summary = N_( "SSL Connect failed" ),
- };
-
- ((SSL_ERROR_MESSAGE *) message)->popup = &popup;
-
- return -1;
-
- }
-
- //
- // Success.
- //
-
- // Get peer certificate, notify application before validation.
- lib3270_autoptr(X509) peer = SSL_get_peer_certificate(hSession->ssl.con);
-
- if(peer)
- {
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- BIO * out = BIO_new(BIO_s_mem());
- unsigned char * data;
- unsigned char * text;
- int n;
-
- X509_print(out,peer);
-
- n = BIO_get_mem_data(out, &data);
- text = (unsigned char *) malloc (n+1);
- text[n] ='\0';
- memcpy(text,data,n);
-
- trace_ssl(hSession,"TLS/SSL peer certificate:\n%s\n",text);
-
- free(text);
- BIO_free(out);
-
- }
-
- hSession->cbk.set_peer_certificate(peer);
-
-#ifdef SSL_ENABLE_CRL_CHECK
-
- if(!hSession->ssl.crl.cert)
- {
- if(lib3270_crl_new_from_x509(hSession, message, peer))
- return EACCES;
- }
-
-#endif // SSL_ENABLE_CRL_CHECK
-
- }
-
-#ifdef SSL_ENABLE_CRL_CHECK
- if(SSL_get_verify_result(hSession->ssl.con) == X509_V_ERR_UNABLE_TO_GET_CRL && hSession->ssl.crl.cert && peer)
- {
- //
- // Verify CRL
- //
- // References:
- //
- // http://www.zedwood.com/article/cpp-check-crl-for-revocation
- //
-
- trace_ssl(hSession,"Doing CRL check using %s\n",hSession->ssl.crl.url);
-
- // Got CRL, verify it!
- // Reference: https://stackoverflow.com/questions/10510850/how-to-verify-the-certificate-for-the-ongoing-ssl-session
- X509_STORE_CTX *csc = X509_STORE_CTX_new();
- X509_STORE_CTX_set_verify_cb(csc, x509_store_ctx_error_callback);
- X509_STORE_CTX_init(csc, SSL_CTX_get_cert_store(ssl_ctx), peer, NULL);
-
- if(X509_verify_cert(csc) != 1)
- rv = X509_STORE_CTX_get_error(csc);
- else
- rv = X509_V_OK;
-
- trace_ssl(hSession, "X509_verify_cert error code was %d", rv);
-
- SSL_set_verify_result(hSession->ssl.con, rv);
-
- X509_STORE_CTX_free(csc);
-
- }
-#endif // SSL_ENABLE_CRL_CHECK
-
- // Check validation state.
- rv = SSL_get_verify_result(hSession->ssl.con);
- debug("SSL Verify result was %d", rv);
- const struct ssl_status_msg * msg = ssl_get_status_from_error_code((long) rv);
-
- if(!msg)
- {
- trace_ssl(hSession,"Unexpected or invalid TLS/SSL verify result %d\n",rv);
- set_ssl_state(hSession,LIB3270_SSL_UNSECURE);
-
- static LIB3270_POPUP popup = {
- .summary = N_( "Can't verify." ),
- .body = N_( "Unexpected or invalid TLS/SSL verify result" )
- };
-
- ((SSL_ERROR_MESSAGE *) message)->popup = &popup;
- return EACCES;
-
- }
- else
- {
- switch(rv)
- {
- case X509_V_OK:
- trace_ssl(hSession,"TLS/SSL negotiated connection complete. Peer certificate %s presented.\n", peer ? "was" : "was not");
- set_ssl_state(hSession,LIB3270_SSL_SECURE);
- break;
-
- case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
-
- trace_ssl(hSession,"TLS/SSL negotiated connection complete with self signed certificate in certificate chain (rc=%d)\n",rv);
-
- set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED);
-
-#ifdef SSL_ENABLE_SELF_SIGNED_CERT_CHECK
- static const LIB3270_POPUP popup = {
- .type = LIB3270_NOTIFY_SECURE,
- .summary = N_( "The SSL certificate for this host is not trusted." ),
- .body = N_( "The security certificate presented by this host was not issued by a trusted certificate authority." )
- };
-
- ((SSL_ERROR_MESSAGE *) message)->popup = &popup;
- return EACCES;
-#else
- break;
-#endif // SSL_ENABLE_SELF_SIGNED_CERT_CHECK
-
- case X509_V_ERR_UNABLE_TO_GET_CRL:
-
- trace_ssl(hSession,"TLS/SSL verify result was %d (%s)\n", rv, msg->body);
-
- ((SSL_ERROR_MESSAGE *) message)->popup = (LIB3270_POPUP *) msg;
-
- debug("message: %s",((SSL_ERROR_MESSAGE *) message)->popup->summary);
- debug("description: %s",((SSL_ERROR_MESSAGE *) message)->popup->body);
-
- set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED);
-
- if(msg->type == LIB3270_NOTIFY_ERROR && lib3270_ssl_get_crl_download(hSession))
- return EACCES;
-
- break;
-
- default:
- trace_ssl(hSession,"TLS/SSL verify result was %d (%s)\n", rv, msg->body);
-
- ((SSL_ERROR_MESSAGE *) message)->popup = (LIB3270_POPUP *) msg;
-
- debug("message: %s",((SSL_ERROR_MESSAGE *) message)->popup->summary);
- debug("description: %s",((SSL_ERROR_MESSAGE *) message)->popup->body);
-
- set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED);
-
- if(msg->type == LIB3270_NOTIFY_ERROR)
- return EACCES;
-
- }
-
- }
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- char buffer[4096];
- int alg_bits = 0;
- const SSL_CIPHER * cipher = SSL_get_current_cipher(hSession->ssl.con);
-
- trace_ssl(hSession,"TLS/SSL cipher description: %s",SSL_CIPHER_description((SSL_CIPHER *) cipher, buffer, 4095));
- SSL_CIPHER_get_bits(cipher, &alg_bits);
- trace_ssl(hSession,"%s version %s with %d bits\n",
- SSL_CIPHER_get_name(cipher),
- SSL_CIPHER_get_version(cipher),
- alg_bits);
- }
-
- return 0;
-}
-
-int ssl_negotiate(H3270 *hSession)
-{
- int rc;
- SSL_ERROR_MESSAGE msg;
-
- memset(&msg,0,sizeof(msg));
-
- set_ssl_state(hSession,LIB3270_SSL_NEGOTIATING);
- non_blocking(hSession,False);
-
- rc = lib3270_run_task(hSession, background_ssl_negotiation, &msg);
-
- debug("background_ssl_negotiation exits with rc=%d",rc);
- if(rc && msg.popup)
- {
- // SSL Negotiation has failed.
- if(popup_ssl_error(hSession,rc,&msg))
- {
- host_disconnect(hSession,1); // Disconnect with "failed" status.
- return rc;
- }
-
- } else if(rc) {
-
- // SSL Negotiation has failed, no popup to present.
- const LIB3270_POPUP popup = {
- .summary = N_("SSL negotiation has failed")
- };
-
- msg.popup = &popup;
- if(popup_ssl_error(hSession,rc,&msg))
- {
- host_disconnect(hSession,1); // Disconnect with "failed" status.
- return rc;
- }
-
- }
-
- // Tell the world that we are (still) connected, now in secure mode.
- lib3270_set_connected_initial(hSession);
- non_blocking(hSession,True);
-
- return 0;
-}
-
-
-int ssl_init(H3270 *hSession) {
-
- int rc;
- SSL_ERROR_MESSAGE msg;
-
- memset(&msg,0,sizeof(msg));
-
- non_blocking(hSession,False);
-
- rc = lib3270_run_task(hSession, background_ssl_init, &msg);
- if(rc)
- {
- // SSL init has failed.
- host_disconnect(hSession,1); // Disconnect with "failed" status.
-
- if(msg.popup)
- {
- ssl_popup_message(hSession,&msg);
- }
- else
- {
- LIB3270_POPUP popup = {
- .summary = N_("Unexpected error on SSL initialization")
- };
-
- lib3270_autoptr(char) body = lib3270_strdup_printf("%s (rc=%d)",strerror(rc),rc);
- popup.body = body;
-
- msg.popup = &popup;
- ssl_popup_message(hSession,&msg);
- msg.popup = NULL;
-
- }
-
-
- }
-
- non_blocking(hSession,True);
-
- return rc;
-
-}
-
-#endif /*]*/
-
diff --git a/src/ssl/notify.c b/src/ssl/notify.c
deleted file mode 100644
index 0ba3706..0000000
--- a/src/ssl/notify.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- *
- */
-
-
-#include
-#include
-#include
-#include
-#include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-#if defined(HAVE_LIBSSLx)
-
-#include
-
-/**
- * @brief Translate strings from ssl error message.
- *
- * @param msg SSL error message descriptor.
- * @param rc Value of errno.
- *
- * @return Dynamically allocated popup description.
- *
- */
-static LIB3270_POPUP * translate_ssl_error_message(const SSL_ERROR_MESSAGE *msg, int rc)
-{
- LIB3270_POPUP * popup;
-
- printf("\n\nMSG-CODE=%d\n\n",msg->code);
-
- const char *body = (msg->body ? msg->body : msg->popup->body);
-
- if(msg->code)
- {
- if(body)
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "%s\nThe SSL error message was \"%s\"(%d)" ),
- dgettext(GETTEXT_PACKAGE,body),
- ERR_reason_error_string(msg->code),
- msg->code
- );
- }
- else
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "The SSL error message was \"%s\" (%d)" ),
- ERR_reason_error_string(msg->code),
- msg->code
- );
- }
-
- }
-#ifdef _WIN32
- else if(msg->lasterror)
- {
- lib3270_autoptr(char) windows_error = lib3270_win32_translate_error_code(msg->lasterror);
-
- if(body)
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "%s\nThe windows error was \"%s\" (%u)" ),
- dgettext(GETTEXT_PACKAGE,body),
- windows_error,
- (unsigned int) msg->lasterror
- );
- }
- else
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "Windows error was \"%s\" (%u)" ),
- windows_error,
- (unsigned int) msg->lasterror
- );
- }
-
- }
-#endif // _WIN32
- else if(rc)
- {
- if(body)
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "%s\nThe operating system error was \"%s\" (%u)" ),
- dgettext(GETTEXT_PACKAGE,body),
- strerror(rc),
- rc
- );
- }
- else
- {
- popup = lib3270_popup_clone_printf(
- msg->popup,
- _( "The operating system error was \"%s\" (%u)" ),
- strerror(rc),
- rc
- );
- }
-
- }
- else
- {
- popup = lib3270_malloc(sizeof(LIB3270_POPUP));
- *popup = *msg->popup;
-
- if(body)
- popup->body = dgettext(GETTEXT_PACKAGE,body);
-
- }
-
- popup->summary = dgettext(GETTEXT_PACKAGE,msg->popup->summary);
-
- debug("%s: names[\"%s\",\"%s\"]",__FUNCTION__,popup->name, msg->popup->name);
-
- if(popup->title)
- popup->title = dgettext(GETTEXT_PACKAGE,popup->title);
- else
- popup->title = _("Your connection is not safe");
-
- popup->label = _("Continue");
- return popup;
-}
-
-
-int popup_ssl_error(H3270 GNUC_UNUSED(*hSession), int rc, const SSL_ERROR_MESSAGE *msg)
-{
- int response = 0;
-
- LIB3270_POPUP * popup = translate_ssl_error_message(msg,0);
-
-#ifdef _WIN32
-
- lib3270_autoptr(char) rcMessage = lib3270_strdup_printf("The error code was %d",rc);
-
- const char *outMsg[] = {
- popup->title,
- popup->summary,
- (popup->body ? popup->body : ""),
- rcMessage
- };
-
- ReportEvent(
- hEventLog,
- EVENTLOG_ERROR_TYPE,
- 1,
- 0,
- NULL,
- (sizeof(outMsg)/sizeof(outMsg[0])),
- 0,
- outMsg,
- NULL
- );
-
-#else
-
- lib3270_write_log(hSession, "SSL", "%s %s (rc=%d)", popup->summary, (popup->body ? popup->body : ""), rc);
-
-#endif // _WIN32
-
-#ifdef SSL_ENABLE_NOTIFICATION_WHEN_FAILED
-
- response = hSession->cbk.popup(hSession,popup,1);
-
-#endif // SSL_ENABLE_NOTIFICATION_WHEN_FAILED
-
- lib3270_free(popup);
- return response;
-
-}
-
-void ssl_popup_message(H3270 *hSession, const SSL_ERROR_MESSAGE *msg) {
-
- LIB3270_POPUP * popup = translate_ssl_error_message(msg,0);
- hSession->cbk.popup(hSession,popup,0);
- lib3270_free(popup);
-
-}
-
-#endif // defined(HAVE_LIBSSL)
diff --git a/src/ssl/properties.c b/src/ssl/properties.c
deleted file mode 100644
index a7742e5..0000000
--- a/src/ssl/properties.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- */
-
-#include
-#include
-
-#if defined(HAVE_LIBSSL)
- #include
-#endif
-
-
-/**
- * @brief Get SSL host option.
- *
- * @return Non zero if the host URL has SSL scheme.
- *
- */
-#ifdef HAVE_LIBSSLx
-LIB3270_EXPORT int lib3270_get_secure_host(const H3270 *hSession)
-{
- return hSession->ssl.enabled ? 1 : 0;
-}
-#else
-LIB3270_EXPORT int lib3270_get_secure_host(const H3270 GNUC_UNUSED(*hSession))
-{
- errno = ENOTSUP;
- return 0;
-}
-#endif // HAVE_LIBSSL
-
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
-LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 *hSession)
-{
-
- if(hSession->ssl.crl.cert)
- {
-
- BIO * out = BIO_new(BIO_s_mem());
- unsigned char * data;
- unsigned char * text;
- int n;
-
- X509_CRL_print(out,hSession->ssl.crl.cert);
-
- n = BIO_get_mem_data(out, &data);
- text = (unsigned char *) lib3270_malloc(n+1);
- text[n] ='\0';
-
- memcpy(text,data,n);
- BIO_free(out);
-
- return (char *) text;
-
- }
-
- return NULL;
-
-}
-#else
-LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 GNUC_UNUSED(*hSession))
-{
- return NULL;
-}
-#endif // SSL_ENABLE_CRL_CHECK
-
-
-LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(const H3270 *hSession)
-{
-#ifdef HAVE_LIBSSLx
- if(hSession->ssl.con)
- {
- X509 * peer = SSL_get_peer_certificate(hSession->ssl.con);
- if(peer)
- {
- BIO * out = BIO_new(BIO_s_mem());
- unsigned char * data;
- unsigned char * text;
- int n;
-
- X509_print(out,peer);
-
- n = BIO_get_mem_data(out, &data);
- text = (unsigned char *) lib3270_malloc(n+1);
- text[n] ='\0';
- memcpy(text,data,n);
- BIO_free(out);
-
- return (char *) text;
- }
- }
-#endif // HAVE_LIBSSL
-
- return NULL;
-}
-
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- const char * lib3270_crl_get_url(const H3270 *hSession)
- {
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
- if(hSession->ssl.crl.url)
- return hSession->ssl.crl.url;
-
-#ifdef SSL_CRL_URL
- return SSL_CRL_URL;
-#else
- return getenv("LIB3270_DEFAULT_CRL");
-#endif // SSL_CRL_URL
-
-#else
- errno = ENOTSUP;
- return "";
-#endif
- }
- #pragma GCC diagnostic pop
-
- #pragma GCC diagnostic push
- #pragma GCC diagnostic ignored "-Wunused-parameter"
- int lib3270_crl_set_url(H3270 *hSession, const char *crl)
- {
-
- FAIL_IF_ONLINE(hSession);
-
-#if defined(HAVE_LIBSSLx) && defined(SSL_ENABLE_CRL_CHECK)
-
- if(hSession->ssl.crl.url)
- {
- free(hSession->ssl.crl.url);
- hSession->ssl.crl.url = NULL;
- }
-
- if(hSession->ssl.crl.cert)
- {
- X509_CRL_free(hSession->ssl.crl.cert);
- hSession->ssl.crl.cert = NULL;
- }
-
- if(crl)
- {
- hSession->ssl.crl.url = strdup(crl);
- }
-
- return 0;
-
-#else
-
- return errno = ENOTSUP;
-
-#endif // SSL_ENABLE_CRL_CHECK
-
- }
- #pragma GCC diagnostic pop
-
- const char ** lib3270_crl_get_available_protocols(void)
- {
- static const char * protocols[] =
- {
-#ifdef HAVE_LDAP
- "ldap",
-#endif // HAVE_LDAP
-
-#if defined(_WIN32) || defined(HAVE_LIBCURL)
- "http",
-#endif // _WIN32 || LIBCURL
-
- NULL
- };
-
- return protocols;
- }
-
-
diff --git a/src/ssl/windows/curl.c b/src/ssl/windows/curl.c
deleted file mode 100644
index d589c0c..0000000
--- a/src/ssl/windows/curl.c
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBCURL)
-
-#include "private.h"
-#include
-#include
-
-#define CRL_DATA_LENGTH 2048
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_CURL(CURL **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- curl_easy_cleanup(*ptr);
- *ptr = NULL;
-}
-
-typedef struct _curldata
-{
- size_t length;
- H3270 * hSession;
- SSL_ERROR_MESSAGE * message;
- char errbuf[CURL_ERROR_SIZE];
- struct {
- size_t length;
- unsigned char * contents;
- } data;
-} CURLDATA;
-
-static inline void lib3270_autoptr_cleanup_CURLDATA(CURLDATA **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- {
- CURLDATA *cdata = *ptr;
-
- if(cdata->data.contents) {
- lib3270_free(cdata->data.contents);
- cdata->data.contents = NULL;
- }
- lib3270_free(cdata);
- }
- *ptr = NULL;
-}
-
-static inline void lib3270_autoptr_cleanup_BIO(BIO **ptr)
-{
- debug("%s(%p)",__FUNCTION__,*ptr);
- if(*ptr)
- BIO_free_all(*ptr);
- *ptr = NULL;
-}
-
-static size_t internal_curl_write_callback(void *contents, size_t size, size_t nmemb, void *userp)
-{
- CURLDATA * data = (CURLDATA *) userp;
-
- size_t realsize = size * nmemb;
- size_t ix;
-
- debug("Received %u bytes (datablock is %p)", (unsigned int) realsize, data);
-
- unsigned char *ptr = (unsigned char *) contents;
-
- if(lib3270_get_toggle(data->hSession,LIB3270_TOGGLE_SSL_TRACE))
- lib3270_trace_data(data->hSession,"curl_write:",(const char *) contents, realsize);
-
- if((realsize + data->length) > data->data.length)
- {
- data->data.length += (CRL_DATA_LENGTH + realsize);
- data->data.contents = lib3270_realloc(data->data.contents,data->data.length);
-
- for(ix = data->length; ix < data->data.length; ix++)
- {
- data->data.contents[ix] = 0;
- }
-
- }
-
- for(ix = 0; ix < realsize; ix++)
- {
- data->data.contents[data->length++] = *(ptr++);
- }
-
- return realsize;
-}
-
-static int internal_curl_trace_callback(CURL GNUC_UNUSED(*handle), curl_infotype type, char *data, size_t size, void *userp)
-{
- const char * text = NULL;
-
- switch (type) {
- case CURLINFO_TEXT:
- lib3270_write_log(((CURLDATA *) userp)->hSession,"curl","%s",data);
- return 0;
-
- case CURLINFO_HEADER_OUT:
- text = "=> Send header";
- break;
-
- case CURLINFO_DATA_OUT:
- text = "=> Send data";
- break;
-
- case CURLINFO_SSL_DATA_OUT:
- text = "=> Send SSL data";
- break;
-
- case CURLINFO_HEADER_IN:
- text = "<= Recv header";
- break;
-
- case CURLINFO_DATA_IN:
- text = "<= Recv data";
- break;
-
- case CURLINFO_SSL_DATA_IN:
- text = "<= Recv SSL data";
- break;
-
- default:
- return 0;
-
- }
-
- lib3270_trace_data(
- ((CURLDATA *) userp)->hSession,
- text,
- data,
- size
- );
-
- return 0;
-}
-
-X509_CRL * get_crl_using_curl(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- lib3270_autoptr(CURLDATA) crl_data = lib3270_malloc(sizeof(CURLDATA));
- lib3270_autoptr(CURL) hCurl = curl_easy_init();
-
- memset(crl_data,0,sizeof(CURLDATA));
- crl_data->message = message;
- crl_data->hSession = hSession;
- crl_data->data.length = CRL_DATA_LENGTH;
- crl_data->data.contents = lib3270_malloc(crl_data->data.length);
-
- if(!hCurl)
- {
- message->title = _( "Security error" );
- message->text = _( "Error loading certificate revocation list" );
- message->description = _( "Can't initialize curl operation" );
- return NULL;
- }
-
- CURLcode res;
-
- curl_easy_setopt(hCurl, CURLOPT_URL, consturl);
- curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION, 1L);
-
- curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, crl_data->errbuf);
-
- curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, internal_curl_write_callback);
- curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *) crl_data);
-
- curl_easy_setopt(hCurl, CURLOPT_USERNAME, "");
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- curl_easy_setopt(hCurl, CURLOPT_VERBOSE, 1L);
- curl_easy_setopt(hCurl, CURLOPT_DEBUGFUNCTION, internal_curl_trace_callback);
- curl_easy_setopt(hCurl, CURLOPT_DEBUGDATA, (void *) crl_data);
- }
-
- res = curl_easy_perform(hCurl);
-
- if(res != CURLE_OK)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
-
- if(crl_data->errbuf[0])
- {
- message->text = curl_easy_strerror(res);
- message->description = crl_data->errbuf;
- }
- else
- {
- message->text = _( "Error loading certificate revocation list" );
- message->description = curl_easy_strerror(res);
- }
-
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description);
- errno = EINVAL;
- return NULL;
-
- }
-
- char *ct = NULL;
- res = curl_easy_getinfo(hCurl, CURLINFO_CONTENT_TYPE, &ct);
- if(res != CURLE_OK)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Error loading certificate revocation list" );
- message->description = curl_easy_strerror(res);
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description);
- errno = EINVAL;
- return NULL;
- }
-
- if(lib3270_get_toggle(crl_data->hSession,LIB3270_TOGGLE_SSL_TRACE))
- lib3270_trace_data(crl_data->hSession,"CRL Data",(const char *) crl_data->data.contents, (unsigned int) crl_data->length);
-
- if(ct)
- {
- const unsigned char * data = crl_data->data.contents;
-
- if(strcasecmp(ct,"application/pkix-crl") == 0)
- {
- // CRL File, convert it
- if(!d2i_X509_CRL(&x509_crl, &data, crl_data->length))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list" );
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text);
- return NULL;
- }
- }
- else
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Got an invalid certificate revocation list from server" );
- lib3270_write_log(hSession,"ssl","%s: content-type unexpected: \"%s\"",consturl, ct);
- errno = EINVAL;
- return NULL;
- }
- }
- else if(strncasecmp(consturl,"ldap://",7) == 0)
- {
- //
- // curl's LDAP query on windows returns diferently. Working with it.
- //
-#ifdef DEBUG
- {
- FILE *out = fopen("downloaded.crl","w");
- if(out)
- {
- fwrite(crl_data->data.contents,crl_data->length,1,out);
- fclose(out);
- }
-
- }
-#endif
-
- char * attr = strchr(consturl,'?');
- if(!attr)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "No attribute in LDAP search URL" );
- errno = ENOENT;
- return NULL;
- }
-
- attr++;
-
- lib3270_autoptr(char) text = lib3270_strdup_printf("No mime-type, extracting \"%s\" directly from LDAP response\n",attr);
- trace_ssl(crl_data->hSession, text);
-
- lib3270_autoptr(char) key = lib3270_strdup_printf("%s: ",attr);
-
-
-// char *ptr = strcasestr((char *) crl_data->data.contents, key);
-
- size_t ix;
- unsigned char *from = NULL;
- size_t keylength = strlen(key);
- for(ix = 0; ix < (crl_data->length - keylength); ix++)
- {
- if(!strncasecmp( (char *) (crl_data->data.contents+ix),key,keylength))
- {
- from = crl_data->data.contents+ix;
- break;
- }
- }
-
- debug("strstr(%s): %p", key, from);
-
- if(!from)
- {
- message->error = hSession->ssl.error = 0;
- message->title = _( "Security error" );
- message->text = _( "Can't find certificate revocation list in LDAP response" );
- errno = ENOENT;
- return NULL;
- }
-
- from += strlen(key);
- size_t length = crl_data->length - (from - crl_data->data.contents);
-
- static const char terminator[] = { 0x0a, 0x0a, 0x09 };
- unsigned char *to = from+length;
-
- for(ix = 0; ix < (length - sizeof(terminator)); ix++)
- {
- if(!memcmp(from+ix,terminator,sizeof(terminator)))
- {
- to = from+ix;
- break;
- }
- }
-
- length = to - from;
-
- if(lib3270_get_toggle(hSession,LIB3270_TOGGLE_SSL_TRACE))
- {
- lib3270_trace_data(
- hSession,
- "CRL Data received from LDAP server",
- (const char *) from,
- length
- );
- }
-
- if(!d2i_X509_CRL(&x509_crl, (const unsigned char **) &from, length))
- {
- message->error = hSession->ssl.error = ERR_get_error();
- message->title = _( "Security error" );
- message->text = _( "Can't decode certificate revocation list got from LDAP Search" );
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text);
- errno = EINVAL;
- return NULL;
- }
-
- }
-
- return x509_crl;
-
-}
-
-#endif // defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK) && defined(HAVE_LIBCURL)
diff --git a/src/ssl/windows/getcrl.c b/src/ssl/windows/getcrl.c
deleted file mode 100644
index e7cde3f..0000000
--- a/src/ssl/windows/getcrl.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-#include
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
-
-#include "private.h"
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-static inline void lib3270_autoptr_cleanup_FILE(FILE **file)
-{
- if(*file)
- fclose(*file);
-}
-
-X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- X509_CRL * x509_crl = NULL;
-
- if(!(consturl && *consturl))
- {
- static const LIB3270_POPUP popup = {
- .name = "CantOpenCRL",
- .summary = N_("Can´t open CRL file"),
- .body = N_("The URL for the CRL is undefined or empty")
- };
-
- message->code = hSession->ssl.error = 0;
- message->popup = &popup;
- errno = ENOENT;
- return NULL;
- }
-
- if(strncasecmp(consturl,"file://",7) == 0)
- {
- lib3270_autoptr(FILE) hCRL = fopen(consturl+7,"r");
-
- if(!hCRL)
- {
- // Can't open CRL File.
- static const LIB3270_POPUP popup = {
- .summary = N_("Can´t open CRL file"),
- .body = N_("Unable to open the defined CRL file")
- };
-
- message->code = errno;
- message->popup = &popup;
- hSession->ssl.error = 0;
- trace_ssl(hSession,"Can't open %s: %s\n",consturl,strerror(errno));
- return NULL;
-
- }
-
- trace_ssl(hSession,"Loading CRL from %s\n",consturl+7);
- if(d2i_X509_CRL_fp(hCRL, &x509_crl))
- {
- static const LIB3270_POPUP popup = {
- .summary = N_("Unable to decode CRL")
- };
-
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, popup.summary);
- return NULL;
- }
-
-
-
- }
-#ifdef HAVE_LDAP
- else if(strncasecmp(consturl,"ldap://",7) == 0 && strlen(consturl) > 8)
- {
- return get_crl_using_ldap(hSession, message, consturl);
-
- }
-#endif // HAVE_LDAP
- else if(strncasecmp(consturl,"http://",7) == 0 && strlen(consturl) > 8)
- {
- return get_crl_using_http(hSession, message, consturl);
- }
- else
- {
-#ifdef HAVE_LIBCURL
-
- return get_crl_using_url(hSession, message, consturl);
-
-#else
- // Can't get CRL.
-
- message->code = hSession->ssl.error = 0;
- if(!message->popup) {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Unexpected or invalid CRL URL" ),
- .body = N_("The URL scheme is unknown")
- };
- message->popup = &popup;
- }
-
- trace_ssl(hSession,"%s: The URL scheme is unknown",consturl);
-
- errno = EINVAL;
- return NULL;
-
-#endif // HAVE_LIBCURL
- }
-
- return x509_crl;
-
-}
-
-#endif // HAVE_LIBSSL && SSL_ENABLE_CRL_CHECK
diff --git a/src/ssl/windows/http.c b/src/ssl/windows/http.c
deleted file mode 100644
index 622e8c2..0000000
--- a/src/ssl/windows/http.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- * References:
- *
- * https://docs.microsoft.com/en-us/windows/win32/winhttp/winhttp-autoproxy-api
- *
- */
-
-/**
- * @brief Implements CRL download using winhttp.
- *
- */
-
-#include
-#include "private.h"
-
-#if defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
-
-#include
-#include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl)
-{
- size_t szResponse = 0;
- const char * error_message = NULL;
- lib3270_autoptr(char) httpText = lib3270_get_from_url(hSession, consturl, &szResponse, &error_message);
-
- if(!httpText)
- {
- static LIB3270_POPUP popup = {
- .summary = N_("Can´t get CRL"),
- };
-
- popup.body = error_message;
- message->popup = &popup;
- message->code = hSession->ssl.error = 0;
- trace_ssl(
- hSession,"Can't get %s: %s\n",
- consturl,
- popup.body ? popup.body : "Undefined message"
- );
- return NULL;
- }
-
- // Copy the pointer because d2i_X509_CRL changes the value!!!
- const unsigned char *crl_data = (const unsigned char *) httpText;
-
- X509_CRL * x509_crl = NULL;
-
- if(!d2i_X509_CRL(&x509_crl,&crl_data, (DWORD) szResponse))
- {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Can't decode certificate revocation list" )
- };
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- lib3270_write_log(hSession,"ssl","%s: %s",consturl, popup.summary);
-
- trace_ssl(
- hSession,"%s: %s\n",
- consturl,
- popup.summary
- );
-
- return NULL;
- }
-
- trace_ssl(hSession,"Got CRL from %s\n",consturl);
-
- return x509_crl;
-
-}
-
-#endif // defined(HAVE_LIBSSL) && defined(SSL_ENABLE_CRL_CHECK)
diff --git a/src/ssl/windows/init.c b/src/ssl/windows/init.c
deleted file mode 100644
index ffe02b7..0000000
--- a/src/ssl/windows/init.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como - e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça)
- *
- *
- * References:
- *
- * http://www.openssl.org/docs/ssl/
- * https://stackoverflow.com/questions/4389954/does-openssl-automatically-handle-crls-certificate-revocation-lists-now
- *
- */
-
-/**
- * @brief OpenSSL initialization for linux.
- *
- */
-
-#include
-#include
-#include
-
-#if defined(HAVE_LIBSSL)
-
-#include
-#include
-#include
-
-#ifndef SSL_ST_OK
- #define SSL_ST_OK 3
-#endif // !SSL_ST_OK
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "trace_dsc.h"
-
-#include
-
-/*--[ Implement ]------------------------------------------------------------------------------------*/
-
-/**
- * @brief Initialize openssl library.
- *
- * @return 0 if ok, non zero if fails.
- *
- */
-int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message)
-{
- debug("%s ssl_ctx=%p",__FUNCTION__,ssl_ctx);
-
- if(ssl_ctx)
- return 0;
-
- trace_ssl(hSession,"Initializing SSL context.\n");
-
- SSL_load_error_strings();
- SSL_library_init();
-
- ssl_ctx = SSL_CTX_new(SSLv23_method());
- if(ssl_ctx == NULL)
- {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Cant initialize the SSL context." )
- };
-
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
- return -1;
- }
-
- SSL_CTX_set_options(ssl_ctx, SSL_OP_ALL);
- SSL_CTX_set_info_callback(ssl_ctx, ssl_info_callback);
-
- // SSL_CTX_set_default_verify_paths(ssl_ctx);
-
- // Load certs
- // https://stackoverflow.com/questions/9507184/can-openssl-on-windows-use-the-system-certificate-store
- X509_STORE * store = SSL_CTX_get_cert_store(ssl_ctx);
-
- lib3270_autoptr(char) certpath = lib3270_build_data_filename("certs","*.der",NULL);
-
- WIN32_FIND_DATA ffd;
- HANDLE hFind = FindFirstFile(certpath, &ffd);
-
- if(hFind == INVALID_HANDLE_VALUE)
- {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Cant open custom certificate directory." )
- };
-
- message->popup = &popup;
-
- trace_ssl(hSession, _( "Can't open \"%s\" (The Windows error code was %ld)\n" ), certpath, (long) GetLastError());
- }
- else
- {
- do
- {
- char * filename = lib3270_build_data_filename("certs", ffd.cFileName, NULL);
-
- debug("Loading \"%s\"",filename);
-
- FILE *fp = fopen(filename,"r");
- if(!fp) {
-
- trace_ssl(hSession, _( "Can't open \"%s\": %s" ), filename, strerror(errno));
-
- }
- else
- {
- X509 * cert = d2i_X509_fp(fp, NULL);
-
- if(!cert)
- {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Cant read custom certificate file." )
- };
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
-
- trace_ssl(hSession, _( "Can't read \"%s\": %s" ), filename, ERR_lib_error_string(hSession->ssl.error));
- }
- else
- {
-
- if(X509_STORE_add_cert(store, cert) != 1)
- {
- static const LIB3270_POPUP popup = {
- .summary = N_( "Cant load custom certificate file." )
- };
- message->code = hSession->ssl.error = ERR_get_error();
- message->popup = &popup;
-
- trace_ssl(hSession, _( "Can't load \"%s\": %s" ), filename, ERR_lib_error_string(hSession->ssl.error));
- }
-
- X509_free(cert);
- }
-
- fclose(fp);
- }
-
- lib3270_free(filename);
-
- }
- while (FindNextFile(hFind, &ffd) != 0);
-
- }
-
- ssl_3270_ex_index = SSL_get_ex_new_index(0,NULL,NULL,NULL,NULL);
-
-#ifdef SSL_ENABLE_CRL_CHECK
-
- // Enable CRL check
- X509_VERIFY_PARAM *param = X509_VERIFY_PARAM_new();
- X509_VERIFY_PARAM_set_flags(param, X509_V_FLAG_CRL_CHECK);
- X509_STORE_set1_param(store, param);
- X509_VERIFY_PARAM_free(param);
- trace_ssl(hSession,"CRL CHECK was enabled\n");
-
-#endif // SSL_ENABLE_CRL_CHECK
-
- return 0;
-
-}
-
-#endif // HAVE_LIBSSL
diff --git a/src/ssl/windows/private.h b/src/ssl/windows/private.h
deleted file mode 100644
index 70fb98f..0000000
--- a/src/ssl/windows/private.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * "Software G3270, desenvolvido com base nos códigos fontes do WC3270 e X3270
- * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a
- * aplicativos mainframe. Registro no INPI sob o nome G3270.
- *
- * Copyright (C) <2008>
- *
- * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob
- * os termos da GPL v.2 - Licença Pública Geral ', conforme publicado pela
- * Free Software Foundation.
- *
- * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER
- * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO
- * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para
- * obter mais detalhes.
- *
- * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este
- * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin
- * St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Este programa está nomeado como private.h e possui - linhas de código.
- *
- * Contatos:
- *
- * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck)
- * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça)
- *
- */
-
-#ifndef LIB3270_WIN32_SSL_PRIVATE_H_INCLUDED
-
- #define LIB3270_WIN32_SSL_PRIVATE_H_INCLUDED
-
- #include
-
- #include
- #include
-
- #include
- #include
- #include
- #include
-
- #include
- #include
- #include
- #include
- #include
- #include
-
- #ifdef HAVE_LIBCURL
-
- #include
-
- /// @brief Use libcurl to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_url(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LIBCURL
-
- #ifdef HAVE_LDAP
-
- /// @brief Use winldap to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_ldap(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
- #endif // HAVE_LDAP
-
- /// @brief Use winhttp to get CRL.
- LIB3270_INTERNAL X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl);
-
-
-#endif // !LIB3270_WIN32_SSL_PRIVATE_H_INCLUDED
--
libgit2 0.21.2