From 003a136cd42b7fadf93152d077e50c8d3570b440 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Wed, 14 Dec 2011 07:09:18 +0200 Subject: [PATCH] transport: do certificate initialization earlier Call sipe_certificate_init() before connecting to the SIP server. This removes the risk of running into a connection timeout if the key pair generation takes too long. --- src/core/sip-transport.c | 11 +++++++++++ src/core/sipe-certificate.c | 2 +- src/core/sipe-certificate.h | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/sip-transport.c b/src/core/sip-transport.c index 5c1066e7..281dc9da 100644 --- a/src/core/sip-transport.c +++ b/src/core/sip-transport.c @@ -1821,6 +1821,17 @@ void sipe_core_transport_sip_connect(struct sipe_core_public *sipe_public, { struct sipe_core_private *sipe_private = SIPE_CORE_PRIVATE; + /* + * Initializing the certificate sub-system will trigger the generation + * of a cryptographic key pair which takes time. If we do this after we + * have connected to the server then there is a risk that we run into a + * SIP connection timeout. So let's get this out of the way now... + * + * This is currently only needed if the user has selected TLS-DSK. + */ + if (SIPE_CORE_PUBLIC_FLAG_IS(TLS_DSK)) + sipe_certificate_init(sipe_private); + if (server) { /* Use user specified server[:port] */ int port_number = 0; diff --git a/src/core/sipe-certificate.c b/src/core/sipe-certificate.c index 82bd3693..71182808 100644 --- a/src/core/sipe-certificate.c +++ b/src/core/sipe-certificate.c @@ -65,7 +65,7 @@ void sipe_certificate_free(struct sipe_core_private *sipe_private) } } -static gboolean sipe_certificate_init(struct sipe_core_private *sipe_private) +gboolean sipe_certificate_init(struct sipe_core_private *sipe_private) { struct sipe_certificate *sc; struct sipe_cert_crypto *ssc; diff --git a/src/core/sipe-certificate.h b/src/core/sipe-certificate.h index e686e8b2..fcce6db4 100644 --- a/src/core/sipe-certificate.h +++ b/src/core/sipe-certificate.h @@ -56,6 +56,13 @@ gboolean sipe_certificate_tls_dsk_generate(struct sipe_core_private *sipe_privat const gchar *uri); /** + * Initialize certificate data + * + * @param sipe_private SIPE core private data + */ +gboolean sipe_certificate_init(struct sipe_core_private *sipe_private); + +/** * Free certificate data * * @param sipe_private SIPE core private data -- 2.11.4.GIT