diff --git a/src/core/windows/connect.c b/src/core/windows/connect.c index 971eee7..ced762a 100644 --- a/src/core/windows/connect.c +++ b/src/core/windows/connect.c @@ -226,22 +226,16 @@ int net_reconnect(H3270 *hSession, int seconds) // Have windows message, convert charset. char msg[4096]; - strncpy(msg,host.message,4095); - - debug("host.message=\"%s\"",host.message); + snprintf(msg,sizeof(msg),"%s (RC=%d)",host.message,host.rc); if(hEventLog) { // Register on event log lib3270_autoptr(char) username = lib3270_get_user_name(); - snprintf(msg,sizeof(msg),"rc=%d",host.rc); - const char *outMsg[] = { username, "networking", - message, - host.message, msg }; @@ -270,7 +264,8 @@ int net_reconnect(H3270 *hSession, int seconds) iconv_t hConv = iconv_open("UTF-8",lib3270_win32_local_charset()); if(iconv( hConv, - &host.message,&in, + (ICONV_CONST char *) &host.message, + &in, &ptr,&out ) == ((size_t) -1)) { diff --git a/src/ssl/windows/getcrl.c b/src/ssl/windows/getcrl.c index f0558f0..e7cde3f 100644 --- a/src/ssl/windows/getcrl.c +++ b/src/ssl/windows/getcrl.c @@ -53,10 +53,14 @@ X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, co 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"); + 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; } @@ -68,13 +72,15 @@ X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, co 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); + 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; } @@ -82,10 +88,13 @@ X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, co 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); + 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; } @@ -112,16 +121,14 @@ X509_CRL * lib3270_download_crl(H3270 *hSession, SSL_ERROR_MESSAGE * message, co #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"); + 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); diff --git a/src/ssl/windows/http.c b/src/ssl/windows/http.c index cb339ed..e48db64 100644 --- a/src/ssl/windows/http.c +++ b/src/ssl/windows/http.c @@ -49,16 +49,22 @@ X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, const char *consturl) { size_t szResponse = 0; - lib3270_autoptr(char) httpText = lib3270_get_from_url(hSession, consturl, &szResponse, &message->text); + const char * error_message = NULL; + lib3270_autoptr(char) httpText = lib3270_get_from_url(hSession, consturl, &szResponse, &error_message); if(!httpText) { - message->error = hSession->ssl.error = 0; - message->title = _( "Security error" ); + static LIB3270_POPUP popup = { + .summary = N_("Can´t get CRL"), + }; + + popup.body = error_message; + message->popup = error_message; + message->code = hSession->ssl.error = 0; trace_ssl( hSession,"Can't get %s: %s\n", consturl, - message->description ? message->description : "Undefined message" + popup.body ? popup.body : "Undefined message" ); return NULL; } @@ -67,17 +73,20 @@ X509_CRL * get_crl_using_http(H3270 *hSession, SSL_ERROR_MESSAGE * message, cons const unsigned char *crl_data = (const unsigned char *) httpText; X509_CRL * x509_crl = NULL; + if(!d2i_X509_CRL(&x509_crl,&crl_data, (DWORD) szResponse)) { - 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); + 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, - message->text + popup.summary ); return NULL; diff --git a/src/ssl/windows/init.c b/src/ssl/windows/init.c index 26e82c6..ffe02b7 100644 --- a/src/ssl/windows/init.c +++ b/src/ssl/windows/init.c @@ -87,9 +87,12 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message) 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." ); + 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; } @@ -109,8 +112,11 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message) if(hFind == INVALID_HANDLE_VALUE) { - message->title = _( "Security error" ); - message->text = _( "Cant open custom certificate directory." ); + 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()); } @@ -134,9 +140,11 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message) if(!cert) { - message->error = hSession->ssl.error = ERR_get_error(); - message->title = _( "Security error" ); - message->text = _( "Cant read custom certificate file." ); + 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)); } @@ -145,9 +153,11 @@ int ssl_ctx_init(H3270 *hSession, SSL_ERROR_MESSAGE * message) if(X509_STORE_add_cert(store, cert) != 1) { - message->error = hSession->ssl.error = ERR_get_error(); - message->title = _( "Security error" ); - message->text = _( "Cant load custom certificate file." ); + 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)); } -- libgit2 0.21.2