Commit 68f79a5bbefdaaf2d1f62242a5325ced6dfc98bd
1 parent
0f98ce19
Exists in
master
and in
3 other branches
Fixing start tls messages.
Showing
8 changed files
with
79 additions
and
15 deletions
Show diff stats
src/core/connect.c
| @@ -149,8 +149,6 @@ | @@ -149,8 +149,6 @@ | ||
| 149 | NULL | 149 | NULL |
| 150 | ); | 150 | ); |
| 151 | 151 | ||
| 152 | - non_blocking(hSession,True); | ||
| 153 | - | ||
| 154 | if(rc == ENOTSUP) { | 152 | if(rc == ENOTSUP) { |
| 155 | 153 | ||
| 156 | // No support for TLS/SSL in the active network module, the connection is insecure | 154 | // No support for TLS/SSL in the active network module, the connection is insecure |
| @@ -198,13 +196,17 @@ | @@ -198,13 +196,17 @@ | ||
| 198 | set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED); | 196 | set_ssl_state(hSession,LIB3270_SSL_NEGOTIATED); |
| 199 | 197 | ||
| 200 | // Ask user what I can do! | 198 | // Ask user what I can do! |
| 199 | + debug("********************* [%s]",hSession->ssl.message->name); | ||
| 200 | + debug("********************* [%s]",hSession->ssl.message->label); | ||
| 201 | + | ||
| 201 | if(lib3270_popup_translated(hSession,(const LIB3270_POPUP *) hSession->ssl.message,1) == ECANCELED) { | 202 | if(lib3270_popup_translated(hSession,(const LIB3270_POPUP *) hSession->ssl.message,1) == ECANCELED) { |
| 202 | - lib3270_disconnect(hSession); | ||
| 203 | return ECANCELED; | 203 | return ECANCELED; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | + non_blocking(hSession,True); | ||
| 209 | + | ||
| 208 | return 0; | 210 | return 0; |
| 209 | } | 211 | } |
| 210 | 212 |
src/core/linux/connect.c
| @@ -147,13 +147,14 @@ | @@ -147,13 +147,14 @@ | ||
| 147 | 147 | ||
| 148 | if(hSession->network.module->getsockopt(hSession, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) | 148 | if(hSession->network.module->getsockopt(hSession, SOL_SOCKET, SO_ERROR, (char *) &err, &len) < 0) |
| 149 | { | 149 | { |
| 150 | + int err = errno; | ||
| 150 | lib3270_disconnect(hSession); | 151 | lib3270_disconnect(hSession); |
| 151 | lib3270_popup_dialog( | 152 | lib3270_popup_dialog( |
| 152 | hSession, | 153 | hSession, |
| 153 | LIB3270_NOTIFY_ERROR, | 154 | LIB3270_NOTIFY_ERROR, |
| 154 | _( "Network error" ), | 155 | _( "Network error" ), |
| 155 | _( "Unable to get connection state." ), | 156 | _( "Unable to get connection state." ), |
| 156 | - _( "%s" ), strerror(errno) | 157 | + _( "The system error was %s" ), strerror(err) |
| 157 | ); | 158 | ); |
| 158 | return; | 159 | return; |
| 159 | } | 160 | } |
| @@ -180,12 +181,14 @@ | @@ -180,12 +181,14 @@ | ||
| 180 | return; | 181 | return; |
| 181 | } | 182 | } |
| 182 | 183 | ||
| 184 | + if(lib3270_start_tls(hSession)) { | ||
| 185 | + lib3270_disconnect(hSession); | ||
| 186 | + return; | ||
| 187 | + } | ||
| 188 | + | ||
| 183 | hSession->xio.except = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); | 189 | hSession->xio.except = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_EXCEPTION,net_exception,0); |
| 184 | hSession->xio.read = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_READ,net_input,0); | 190 | hSession->xio.read = hSession->network.module->add_poll(hSession,LIB3270_IO_FLAG_READ,net_input,0); |
| 185 | 191 | ||
| 186 | - if(lib3270_start_tls(hSession)) | ||
| 187 | - return; | ||
| 188 | - | ||
| 189 | lib3270_setup_session(hSession); | 192 | lib3270_setup_session(hSession); |
| 190 | lib3270_set_connected_initial(hSession); | 193 | lib3270_set_connected_initial(hSession); |
| 191 | 194 |
src/core/properties/string.c
| @@ -164,7 +164,6 @@ | @@ -164,7 +164,6 @@ | ||
| 164 | .set = NULL // Set value. | 164 | .set = NULL // Set value. |
| 165 | }, | 165 | }, |
| 166 | 166 | ||
| 167 | - /* | ||
| 168 | { | 167 | { |
| 169 | .name = "sslmessage", // Property name. | 168 | .name = "sslmessage", // Property name. |
| 170 | .description = N_( "The security state" ), // Property description. | 169 | .description = N_( "The security state" ), // Property description. |
| @@ -178,7 +177,6 @@ | @@ -178,7 +177,6 @@ | ||
| 178 | .get = lib3270_get_ssl_state_description, // Get value. | 177 | .get = lib3270_get_ssl_state_description, // Get value. |
| 179 | .set = NULL // Set value. | 178 | .set = NULL // Set value. |
| 180 | }, | 179 | }, |
| 181 | - */ | ||
| 182 | 180 | ||
| 183 | { | 181 | { |
| 184 | .name = "oversize", // Property name. | 182 | .name = "oversize", // Property name. |
src/core/telnet.c
| @@ -569,6 +569,8 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | @@ -569,6 +569,8 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | ||
| 569 | 569 | ||
| 570 | nr = hSession->network.module->recv(hSession, buffer, BUFSZ); | 570 | nr = hSession->network.module->recv(hSession, buffer, BUFSZ); |
| 571 | 571 | ||
| 572 | + debug("%s: recv=%d",__FUNCTION__,nr); | ||
| 573 | + | ||
| 572 | if (nr < 0) | 574 | if (nr < 0) |
| 573 | { | 575 | { |
| 574 | if (nr == -EWOULDBLOCK) | 576 | if (nr == -EWOULDBLOCK) |
| @@ -578,6 +580,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | @@ -578,6 +580,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | ||
| 578 | 580 | ||
| 579 | if(HALF_CONNECTED && nr == -EAGAIN) | 581 | if(HALF_CONNECTED && nr == -EAGAIN) |
| 580 | { | 582 | { |
| 583 | + debug("%s: Received a -EAGAIN with half-connect",__FUNCTION__); | ||
| 581 | connection_complete(hSession); | 584 | connection_complete(hSession); |
| 582 | return; | 585 | return; |
| 583 | } | 586 | } |
| @@ -598,6 +601,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | @@ -598,6 +601,7 @@ void net_input(H3270 *hSession, int GNUC_UNUSED(fd), LIB3270_IO_FLAG GNUC_UNUSED | ||
| 598 | // Process the data. | 601 | // Process the data. |
| 599 | if (HALF_CONNECTED) | 602 | if (HALF_CONNECTED) |
| 600 | { | 603 | { |
| 604 | + debug("%s: Received a %d with half-connect",__FUNCTION__,nr); | ||
| 601 | if (non_blocking(hSession,False) < 0) | 605 | if (non_blocking(hSession,False) < 0) |
| 602 | { | 606 | { |
| 603 | host_disconnect(hSession,True); | 607 | host_disconnect(hSession,True); |
src/core/toggles/init.c
| @@ -79,15 +79,14 @@ static void toggle_nop(H3270 GNUC_UNUSED(*session), const struct lib3270_toggle | @@ -79,15 +79,14 @@ static void toggle_nop(H3270 GNUC_UNUSED(*session), const struct lib3270_toggle | ||
| 79 | 79 | ||
| 80 | static void toggle_keepalive(H3270 *hSession, const struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt)) | 80 | static void toggle_keepalive(H3270 *hSession, const struct lib3270_toggle GNUC_UNUSED(*t), LIB3270_TOGGLE_TYPE GNUC_UNUSED(tt)) |
| 81 | { | 81 | { |
| 82 | - if(hSession->network.context) | 82 | + if(hSession->network.module->is_connected(hSession)) |
| 83 | { | 83 | { |
| 84 | - // Has network context, update keep-alive option | 84 | + // Has network connection, update keep-alive option |
| 85 | int optval = t->value ? 1 : 0; | 85 | int optval = t->value ? 1 : 0; |
| 86 | 86 | ||
| 87 | if(hSession->network.module->setsockopt(hSession, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) | 87 | if(hSession->network.module->setsockopt(hSession, SOL_SOCKET, SO_KEEPALIVE, &optval, sizeof(optval)) < 0) |
| 88 | { | 88 | { |
| 89 | - if(errno != ENOTCONN) | ||
| 90 | - popup_a_sockerr(hSession, _( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); | 89 | + popup_a_sockerr(hSession, _( "Can't %s network keep-alive" ), optval ? _( "enable" ) : _( "disable" )); |
| 91 | } | 90 | } |
| 92 | else | 91 | else |
| 93 | { | 92 | { |
src/network_modules/openssl/main.c
| @@ -194,10 +194,12 @@ static int openssl_network_is_connected(const H3270 *hSession) { | @@ -194,10 +194,12 @@ static int openssl_network_is_connected(const H3270 *hSession) { | ||
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | static int openssl_network_setsockopt(H3270 *hSession, int level, int optname, const void *optval, size_t optlen) { | 196 | static int openssl_network_setsockopt(H3270 *hSession, int level, int optname, const void *optval, size_t optlen) { |
| 197 | + debug("%s(%d)",__FUNCTION__,hSession->network.context->sock); | ||
| 197 | return setsockopt(hSession->network.context->sock, level, optname, optval, optlen); | 198 | return setsockopt(hSession->network.context->sock, level, optname, optval, optlen); |
| 198 | } | 199 | } |
| 199 | 200 | ||
| 200 | static int openssl_network_getsockopt(H3270 *hSession, int level, int optname, void *optval, socklen_t *optlen) { | 201 | static int openssl_network_getsockopt(H3270 *hSession, int level, int optname, void *optval, socklen_t *optlen) { |
| 202 | + debug("%s(%d)",__FUNCTION__,hSession->network.context->sock); | ||
| 201 | return getsockopt(hSession->network.context->sock, level, optname, optval, optlen); | 203 | return getsockopt(hSession->network.context->sock, level, optname, optval, optlen); |
| 202 | } | 204 | } |
| 203 | 205 |
src/network_modules/openssl/messages.c
| @@ -66,10 +66,12 @@ const LIB3270_SSL_MESSAGE * lib3270_openssl_message_from_id(long id) { | @@ -66,10 +66,12 @@ const LIB3270_SSL_MESSAGE * lib3270_openssl_message_from_id(long id) { | ||
| 66 | { | 66 | { |
| 67 | .id = X509_V_ERR_UNABLE_TO_GET_CRL, | 67 | .id = X509_V_ERR_UNABLE_TO_GET_CRL, |
| 68 | .message = { | 68 | .message = { |
| 69 | + .name = "X509UnableToGetCRL", | ||
| 69 | .type = LIB3270_NOTIFY_ERROR, | 70 | .type = LIB3270_NOTIFY_ERROR, |
| 70 | - .icon = "dialog-error", | 71 | + .icon = "security-low", |
| 71 | .summary = N_( "Unable to get certificate CRL." ), | 72 | .summary = N_( "Unable to get certificate CRL." ), |
| 72 | - .body = N_( "The Certificate revocation list (CRL) of a certificate could not be found." ) | 73 | + .body = N_( "The Certificate revocation list (CRL) of a certificate could not be found." ), |
| 74 | + .label = N_( "Continue" ) | ||
| 73 | } | 75 | } |
| 74 | }, | 76 | }, |
| 75 | 77 |
src/network_modules/state.c
| @@ -75,3 +75,57 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) | @@ -75,3 +75,57 @@ void set_ssl_state(H3270 *hSession, LIB3270_SSL_STATE state) | ||
| 75 | 75 | ||
| 76 | hSession->cbk.update_ssl(hSession,hSession->ssl.state); | 76 | hSession->cbk.update_ssl(hSession,hSession->ssl.state); |
| 77 | } | 77 | } |
| 78 | + | ||
| 79 | +LIB3270_EXPORT const char * lib3270_get_ssl_state_message(const H3270 *hSession) { | ||
| 80 | + | ||
| 81 | + if(hSession->ssl.message) { | ||
| 82 | + | ||
| 83 | + if(hSession->ssl.message->summary) | ||
| 84 | + return dgettext(GETTEXT_PACKAGE,hSession->ssl.message->summary); | ||
| 85 | + | ||
| 86 | + return ""; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + return _( "The connection is insecure" ); | ||
| 90 | + | ||
| 91 | +} | ||
| 92 | + | ||
| 93 | +LIB3270_EXPORT const char * lib3270_get_ssl_state_icon_name(const H3270 *hSession) { | ||
| 94 | + | ||
| 95 | + if(hSession->ssl.message && hSession->ssl.message->icon) | ||
| 96 | + return hSession->ssl.message->icon; | ||
| 97 | + | ||
| 98 | + return "dialog-error"; | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +LIB3270_EXPORT const char * lib3270_get_ssl_state_description(const H3270 *hSession) { | ||
| 102 | + | ||
| 103 | + if(hSession->ssl.message) { | ||
| 104 | + | ||
| 105 | + if(hSession->ssl.message->body) | ||
| 106 | + return dgettext(GETTEXT_PACKAGE,hSession->ssl.message->body); | ||
| 107 | + | ||
| 108 | + return ""; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + return ""; | ||
| 112 | + | ||
| 113 | +} | ||
| 114 | + | ||
| 115 | +LIB3270_EXPORT char * lib3270_get_ssl_crl_text(const H3270 *hSession) { | ||
| 116 | + | ||
| 117 | +#ifndef DEBUG | ||
| 118 | + #error Implementar! | ||
| 119 | +#endif // DEBUG | ||
| 120 | + | ||
| 121 | + return NULL; | ||
| 122 | +} | ||
| 123 | + | ||
| 124 | +LIB3270_EXPORT char * lib3270_get_ssl_peer_certificate_text(const H3270 *hSession) { | ||
| 125 | + | ||
| 126 | +#ifndef DEBUG | ||
| 127 | + #error Implementar! | ||
| 128 | +#endif // DEBUG | ||
| 129 | + | ||
| 130 | + return NULL; | ||
| 131 | +} |