diff options
| author | Lars Magne Ingebrigtsen | 2010-09-27 16:35:22 +0200 |
|---|---|---|
| committer | Lars Magne Ingebrigtsen | 2010-09-27 16:35:22 +0200 |
| commit | d2e9d0bbb2d63fc9588d8b2a13b46be8c67dd944 (patch) | |
| tree | 18d0ef16bc60414186e2da5848266546f5ce077f /src | |
| parent | 14db1c41108e7d2874ec9c5fb653f154228acd7b (diff) | |
| download | emacs-d2e9d0bbb2d63fc9588d8b2a13b46be8c67dd944.tar.gz emacs-d2e9d0bbb2d63fc9588d8b2a13b46be8c67dd944.zip | |
Add debugging to the gnutls library, and finish handshaking when it's done.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 4 | ||||
| -rw-r--r-- | src/gnutls.c | 38 |
2 files changed, 13 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index b5962a1dd8b..85a623bed50 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,7 @@ | |||
| 1 | 2010-09-27 Lars Magne Ingebrigtsen <larsi@gnus.org> | ||
| 2 | |||
| 3 | * gnutls.c (gnutls_log_function): Added more debugging. | ||
| 4 | |||
| 1 | 2010-09-27 Kenichi Handa <handa@m17n.org> | 5 | 2010-09-27 Kenichi Handa <handa@m17n.org> |
| 2 | 6 | ||
| 3 | These changes are to remove restriction on the number of glyphs in | 7 | These changes are to remove restriction on the number of glyphs in |
diff --git a/src/gnutls.c b/src/gnutls.c index 50bf7940119..ff538328984 100644 --- a/src/gnutls.c +++ b/src/gnutls.c | |||
| @@ -221,6 +221,10 @@ Lisp_Object gnutls_emacs_global_deinit (void) | |||
| 221 | return gnutls_make_error (GNUTLS_E_SUCCESS); | 221 | return gnutls_make_error (GNUTLS_E_SUCCESS); |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | static void gnutls_log_function (int level, const char* string) { | ||
| 225 | message("debug: %s", string); | ||
| 226 | } | ||
| 227 | |||
| 224 | DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 6, 0, | 228 | DEFUN ("gnutls-boot", Fgnutls_boot, Sgnutls_boot, 3, 6, 0, |
| 225 | doc: /* Initializes client-mode GnuTLS for process PROC. | 229 | doc: /* Initializes client-mode GnuTLS for process PROC. |
| 226 | Currently only client mode is supported. Returns a success/failure | 230 | Currently only client mode is supported. Returns a success/failure |
| @@ -264,6 +268,9 @@ KEYFILE and optionally CALLBACK. */) | |||
| 264 | 268 | ||
| 265 | state = XPROCESS (proc)->gnutls_state; | 269 | state = XPROCESS (proc)->gnutls_state; |
| 266 | 270 | ||
| 271 | gnutls_global_set_log_level(4); | ||
| 272 | gnutls_global_set_log_function(gnutls_log_function); | ||
| 273 | |||
| 267 | /* always initialize globals. */ | 274 | /* always initialize globals. */ |
| 268 | global_init = gnutls_emacs_global_init (); | 275 | global_init = gnutls_emacs_global_init (); |
| 269 | if (! NILP (Fgnutls_errorp (global_init))) | 276 | if (! NILP (Fgnutls_errorp (global_init))) |
| @@ -272,19 +279,13 @@ KEYFILE and optionally CALLBACK. */) | |||
| 272 | /* deinit and free resources. */ | 279 | /* deinit and free resources. */ |
| 273 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC) | 280 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_CRED_ALLOC) |
| 274 | { | 281 | { |
| 275 | message ("gnutls: deallocating certificates"); | ||
| 276 | |||
| 277 | if (EQ (type, Qgnutls_x509pki)) | 282 | if (EQ (type, Qgnutls_x509pki)) |
| 278 | { | 283 | { |
| 279 | message ("gnutls: deallocating x509 certificates"); | ||
| 280 | |||
| 281 | x509_cred = XPROCESS (proc)->x509_cred; | 284 | x509_cred = XPROCESS (proc)->x509_cred; |
| 282 | gnutls_certificate_free_credentials (x509_cred); | 285 | gnutls_certificate_free_credentials (x509_cred); |
| 283 | } | 286 | } |
| 284 | else if (EQ (type, Qgnutls_anon)) | 287 | else if (EQ (type, Qgnutls_anon)) |
| 285 | { | 288 | { |
| 286 | message ("gnutls: deallocating anon certificates"); | ||
| 287 | |||
| 288 | anon_cred = XPROCESS (proc)->anon_cred; | 289 | anon_cred = XPROCESS (proc)->anon_cred; |
| 289 | gnutls_anon_free_client_credentials (anon_cred); | 290 | gnutls_anon_free_client_credentials (anon_cred); |
| 290 | } | 291 | } |
| @@ -296,28 +297,20 @@ KEYFILE and optionally CALLBACK. */) | |||
| 296 | 297 | ||
| 297 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) | 298 | if (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_INIT) |
| 298 | { | 299 | { |
| 299 | message ("gnutls: deinitializing"); | ||
| 300 | |||
| 301 | Fgnutls_deinit (proc); | 300 | Fgnutls_deinit (proc); |
| 302 | } | 301 | } |
| 303 | } | 302 | } |
| 304 | 303 | ||
| 305 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; | 304 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_EMPTY; |
| 306 | 305 | ||
| 307 | message ("gnutls: allocating credentials"); | ||
| 308 | |||
| 309 | if (EQ (type, Qgnutls_x509pki)) | 306 | if (EQ (type, Qgnutls_x509pki)) |
| 310 | { | 307 | { |
| 311 | message ("gnutls: allocating x509 credentials"); | ||
| 312 | |||
| 313 | x509_cred = XPROCESS (proc)->x509_cred; | 308 | x509_cred = XPROCESS (proc)->x509_cred; |
| 314 | if (gnutls_certificate_allocate_credentials (&x509_cred) < 0) | 309 | if (gnutls_certificate_allocate_credentials (&x509_cred) < 0) |
| 315 | memory_full (); | 310 | memory_full (); |
| 316 | } | 311 | } |
| 317 | else if (EQ (type, Qgnutls_anon)) | 312 | else if (EQ (type, Qgnutls_anon)) |
| 318 | { | 313 | { |
| 319 | message ("gnutls: allocating anon credentials"); | ||
| 320 | |||
| 321 | anon_cred = XPROCESS (proc)->anon_cred; | 314 | anon_cred = XPROCESS (proc)->anon_cred; |
| 322 | if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0) | 315 | if (gnutls_anon_allocate_client_credentials (&anon_cred) < 0) |
| 323 | memory_full (); | 316 | memory_full (); |
| @@ -333,8 +326,6 @@ KEYFILE and optionally CALLBACK. */) | |||
| 333 | 326 | ||
| 334 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC; | 327 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_CRED_ALLOC; |
| 335 | 328 | ||
| 336 | message ("gnutls: setting the trustfile"); | ||
| 337 | |||
| 338 | if (EQ (type, Qgnutls_x509pki)) | 329 | if (EQ (type, Qgnutls_x509pki)) |
| 339 | { | 330 | { |
| 340 | if (STRINGP (trustfile)) | 331 | if (STRINGP (trustfile)) |
| @@ -346,12 +337,8 @@ KEYFILE and optionally CALLBACK. */) | |||
| 346 | 337 | ||
| 347 | if (ret < GNUTLS_E_SUCCESS) | 338 | if (ret < GNUTLS_E_SUCCESS) |
| 348 | return gnutls_make_error (ret); | 339 | return gnutls_make_error (ret); |
| 349 | |||
| 350 | message ("gnutls: processed %d CA certificates", ret); | ||
| 351 | } | 340 | } |
| 352 | 341 | ||
| 353 | message ("gnutls: setting the keyfile"); | ||
| 354 | |||
| 355 | if (STRINGP (keyfile)) | 342 | if (STRINGP (keyfile)) |
| 356 | { | 343 | { |
| 357 | ret = gnutls_certificate_set_x509_crl_file | 344 | ret = gnutls_certificate_set_x509_crl_file |
| @@ -361,15 +348,11 @@ KEYFILE and optionally CALLBACK. */) | |||
| 361 | 348 | ||
| 362 | if (ret < GNUTLS_E_SUCCESS) | 349 | if (ret < GNUTLS_E_SUCCESS) |
| 363 | return gnutls_make_error (ret); | 350 | return gnutls_make_error (ret); |
| 364 | |||
| 365 | message ("gnutls: processed %d CRL(s)", ret); | ||
| 366 | } | 351 | } |
| 367 | } | 352 | } |
| 368 | 353 | ||
| 369 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; | 354 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_FILES; |
| 370 | 355 | ||
| 371 | message ("gnutls: gnutls_init"); | ||
| 372 | |||
| 373 | ret = gnutls_init (&state, GNUTLS_CLIENT); | 356 | ret = gnutls_init (&state, GNUTLS_CLIENT); |
| 374 | 357 | ||
| 375 | if (ret < GNUTLS_E_SUCCESS) | 358 | if (ret < GNUTLS_E_SUCCESS) |
| @@ -379,8 +362,6 @@ KEYFILE and optionally CALLBACK. */) | |||
| 379 | 362 | ||
| 380 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT; | 363 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_INIT; |
| 381 | 364 | ||
| 382 | message ("gnutls: setting the priority string"); | ||
| 383 | |||
| 384 | ret = gnutls_priority_set_direct(state, | 365 | ret = gnutls_priority_set_direct(state, |
| 385 | (char*) SDATA (priority_string), | 366 | (char*) SDATA (priority_string), |
| 386 | NULL); | 367 | NULL); |
| @@ -490,15 +471,14 @@ or `gnutls-e-interrupted'. In that case you may resume the handshake | |||
| 490 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; | 471 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_TRANSPORT_POINTERS_SET; |
| 491 | } | 472 | } |
| 492 | 473 | ||
| 493 | message ("gnutls: handshake: handshaking"); | ||
| 494 | ret = gnutls_handshake (state); | 474 | ret = gnutls_handshake (state); |
| 495 | |||
| 496 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_HANDSHAKE_TRIED; | 475 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_HANDSHAKE_TRIED; |
| 497 | 476 | ||
| 498 | if (GNUTLS_E_SUCCESS == ret) | 477 | if (GNUTLS_E_SUCCESS == ret || ret == 0) |
| 499 | { | 478 | { |
| 500 | /* here we're finally done. */ | 479 | /* here we're finally done. */ |
| 501 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_READY; | 480 | GNUTLS_INITSTAGE (proc) = GNUTLS_STAGE_READY; |
| 481 | return Qt; | ||
| 502 | } | 482 | } |
| 503 | 483 | ||
| 504 | return gnutls_make_error (ret); | 484 | return gnutls_make_error (ret); |