Commit 40c509b9f0501dfc6c517a04e4546dce4918e0ec
1 parent
ecc33412
Exists in
master
and in
3 other branches
Updating windows crl downloader.
Showing
2 changed files
with
25 additions
and
36 deletions
Show diff stats
src/lib3270/ssl/linux/getcrl.c
... | ... | @@ -242,13 +242,13 @@ int lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
242 | 242 | message->error = hSession->ssl.error = 0; |
243 | 243 | message->title = N_( "Security error" ); |
244 | 244 | message->text = N_( "Can't open CRL File" ); |
245 | - message->description = strerror(errno); | |
246 | - lib3270_write_log(hSession,"ssl","Can't open %s: %s",consturl,message->description); | |
245 | + message->description = strerror(err); | |
246 | + trace_ssl(hSession,"Can't open %s: %s\n",consturl,message->description); | |
247 | 247 | return err; |
248 | 248 | |
249 | 249 | } |
250 | 250 | |
251 | - lib3270_write_log(hSession,"ssl","Loading CRL from %s",consturl+7); | |
251 | + trace_ssl(hSession,"Loading CRL from %s\n",consturl+7); | |
252 | 252 | d2i_X509_CRL_fp(hCRL, &hSession->ssl.crl.cert); |
253 | 253 | |
254 | 254 | } | ... | ... |
src/lib3270/ssl/windows/getcrl.c
... | ... | @@ -181,9 +181,8 @@ static int internal_curl_trace_callback(CURL *handle unused, curl_infotype type, |
181 | 181 | #endif // HAVE_LIBCURL |
182 | 182 | |
183 | 183 | |
184 | -X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) | |
184 | +int lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) | |
185 | 185 | { |
186 | - X509_CRL * crl = NULL; | |
187 | 186 | const char * consturl = lib3270_get_crl_url(hSession); |
188 | 187 | |
189 | 188 | if(!(consturl && *consturl)) |
... | ... | @@ -192,7 +191,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
192 | 191 | message->title = N_( "Security error" ); |
193 | 192 | message->text = N_( "Can't open CRL File" ); |
194 | 193 | message->description = N_("The URL for the CRL is undefined or empty"); |
195 | - return NULL; | |
194 | + return errno = ENOENT; | |
196 | 195 | } |
197 | 196 | |
198 | 197 | trace_ssl(hSession, "crl=%s\n",consturl); |
... | ... | @@ -204,17 +203,19 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
204 | 203 | if(!hCRL) |
205 | 204 | { |
206 | 205 | // Can't open CRL File. |
206 | + int err = errno; | |
207 | + | |
207 | 208 | message->error = hSession->ssl.error = 0; |
208 | 209 | message->title = N_( "Security error" ); |
209 | 210 | message->text = N_( "Can't open CRL File" ); |
210 | - message->description = strerror(errno); | |
211 | - lib3270_write_log(hSession,"ssl","Can't open %s: %s",consturl,message->description); | |
212 | - return NULL; | |
211 | + message->description = strerror(err); | |
212 | + trace_ssl(hSession,"Can't open %s: %s\n",consturl,message->description); | |
213 | + return err; | |
213 | 214 | |
214 | 215 | } |
215 | 216 | |
216 | - lib3270_write_log(hSession,"ssl","Loading CRL from %s",consturl+7); | |
217 | - d2i_X509_CRL_fp(hCRL, &crl); | |
217 | + trace_ssl(hSession,"Loading CRL from %s\n",consturl+7); | |
218 | + d2i_X509_CRL_fp(hCRL, &hSession->ssl.crl.cert); | |
218 | 219 | |
219 | 220 | } |
220 | 221 | else |
... | ... | @@ -237,7 +238,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
237 | 238 | message->title = N_( "Security error" ); |
238 | 239 | message->text = N_( "Can't initialize curl" ); |
239 | 240 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text); |
240 | - return NULL; | |
241 | + return -1; | |
241 | 242 | } |
242 | 243 | |
243 | 244 | CURLcode res; |
... | ... | @@ -278,7 +279,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
278 | 279 | } |
279 | 280 | |
280 | 281 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description); |
281 | - return NULL; | |
282 | + return -1; | |
282 | 283 | } |
283 | 284 | |
284 | 285 | debug("Tamanho da resposta: %u", (unsigned int) crl_data->length); |
... | ... | @@ -293,21 +294,8 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
293 | 294 | message->text = N_( "Error loading CRL" ); |
294 | 295 | message->description = curl_easy_strerror(res); |
295 | 296 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description); |
296 | - return NULL; | |
297 | - } | |
298 | - | |
299 | - /* | |
300 | - if(lib3270_get_toggle(data->hSession,LIB3270_TOGGLE_SSL_TRACE)) | |
301 | - { | |
302 | - lib3270_autoptr(msg) = lib3270_vsprintf("CRL Data received with content-type \"%s\"", (ct ? ct : "undefined")); | |
303 | - lib3270_trace_data( | |
304 | - data->hSession, | |
305 | - msg, | |
306 | - (const char *) crl_data->contents, | |
307 | - crl_data->length | |
308 | - ); | |
297 | + return -1; | |
309 | 298 | } |
310 | - */ | |
311 | 299 | |
312 | 300 | if(ct) |
313 | 301 | { |
... | ... | @@ -318,13 +306,13 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
318 | 306 | if(strcasecmp(ct,"application/pkix-crl") == 0) |
319 | 307 | { |
320 | 308 | // CRL File, convert it |
321 | - if(!d2i_X509_CRL(&crl, &data, crl_data->length)) | |
309 | + if(!d2i_X509_CRL(&hSession->ssl.crl.cert, &data, crl_data->length)) | |
322 | 310 | { |
323 | 311 | message->error = hSession->ssl.error = ERR_get_error(); |
324 | 312 | message->title = N_( "Security error" ); |
325 | 313 | message->text = N_( "Got an invalid CRL from server" ); |
326 | 314 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text); |
327 | - return NULL; | |
315 | + return -1; | |
328 | 316 | } |
329 | 317 | } |
330 | 318 | else |
... | ... | @@ -333,7 +321,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
333 | 321 | message->title = N_( "Security error" ); |
334 | 322 | message->text = N_( "Got an invalid CRL from server" ); |
335 | 323 | lib3270_write_log(hSession,"ssl","%s: content-type unexpected: \"%s\"",consturl, ct); |
336 | - return NULL; | |
324 | + return -1; | |
337 | 325 | } |
338 | 326 | } |
339 | 327 | else if(strncasecmp(consturl,"ldap://",7) == 0) |
... | ... | @@ -345,7 +333,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
345 | 333 | message->error = hSession->ssl.error = 0; |
346 | 334 | message->title = N_( "Security error" ); |
347 | 335 | message->text = N_( "No attribute in LDAP search URL" ); |
348 | - return NULL; | |
336 | + return errno = ENOENT; | |
349 | 337 | } |
350 | 338 | |
351 | 339 | attr++; |
... | ... | @@ -370,7 +358,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
370 | 358 | message->error = hSession->ssl.error = 0; |
371 | 359 | message->title = N_( "Security error" ); |
372 | 360 | message->text = N_( "Can't find attribute in LDAP response" ); |
373 | - return NULL; | |
361 | + return errno = ENOENT; | |
374 | 362 | } |
375 | 363 | |
376 | 364 | ptr += strlen(key); |
... | ... | @@ -390,7 +378,7 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
390 | 378 | message->error = hSession->ssl.error = 0; |
391 | 379 | message->title = N_( "Security error" ); |
392 | 380 | message->text = N_( "Can't find attribute end in LDAP response" ); |
393 | - return NULL; | |
381 | + return errno = ENOENT; | |
394 | 382 | } |
395 | 383 | |
396 | 384 | length = ix; |
... | ... | @@ -405,12 +393,13 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
405 | 393 | ); |
406 | 394 | } |
407 | 395 | |
408 | - if(!d2i_X509_CRL(&crl, (const unsigned char **) &ptr, length)) | |
396 | + if(!d2i_X509_CRL(&hSession->ssl.crl.cert, (const unsigned char **) &ptr, length)) | |
409 | 397 | { |
410 | 398 | message->error = hSession->ssl.error = ERR_get_error(); |
411 | 399 | message->title = N_( "Security error" ); |
412 | 400 | message->text = N_( "Can't get CRL from LDAP Search" ); |
413 | 401 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->text); |
402 | + return -1; | |
414 | 403 | } |
415 | 404 | |
416 | 405 | } |
... | ... | @@ -422,12 +411,12 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) |
422 | 411 | message->text = N_( "Unexpected or invalid CRL URL" ); |
423 | 412 | message->description = N_("The URL scheme is unknown"); |
424 | 413 | lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description); |
425 | - return NULL; | |
414 | + return errno= EINVAL; | |
426 | 415 | #endif // HAVE_LIBCURL |
427 | 416 | |
428 | 417 | } |
429 | 418 | |
430 | - return crl; | |
419 | + return hSession->ssl.crl.cert == NULL ? -1 : 0; | |
431 | 420 | |
432 | 421 | } |
433 | 422 | ... | ... |