| 48 |
48 |
| 49 #define GAIM_SSL_NSS_DATA(gsc) ((GaimSslNssData *)gsc->private_data) |
49 #define GAIM_SSL_NSS_DATA(gsc) ((GaimSslNssData *)gsc->private_data) |
| 50 |
50 |
| 51 static const PRIOMethods *_nss_methods = NULL; |
51 static const PRIOMethods *_nss_methods = NULL; |
| 52 static PRDescIdentity _identity; |
52 static PRDescIdentity _identity; |
| |
53 |
| |
54 static void |
| |
55 ssl_nss_init_nss(void) |
| |
56 { |
| |
57 PR_Init(PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1); |
| |
58 NSS_NoDB_Init(NULL); |
| |
59 |
| |
60 /* TODO: Fix this so autoconf does the work trying to find this lib. */ |
| |
61 SECMOD_AddNewModule("Builtins", |
| |
62 #ifndef _WIN32 |
| |
63 LIBDIR "/libnssckbi.so", |
| |
64 #else |
| |
65 "nssckbi.dll", |
| |
66 #endif |
| |
67 0, 0); |
| |
68 NSS_SetDomesticPolicy(); |
| |
69 |
| |
70 _identity = PR_GetUniqueIdentity("Gaim"); |
| |
71 _nss_methods = PR_GetDefaultIOMethods(); |
| |
72 } |
| 53 |
73 |
| 54 static SECStatus |
74 static SECStatus |
| 55 ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig, |
75 ssl_auth_cert(void *arg, PRFileDesc *socket, PRBool checksig, |
| 56 PRBool is_server) |
76 PRBool is_server) |
| 57 { |
77 { |
| 263 |
267 |
| 264 static gboolean |
268 static gboolean |
| 265 plugin_load(GaimPlugin *plugin) |
269 plugin_load(GaimPlugin *plugin) |
| 266 { |
270 { |
| 267 #ifdef HAVE_NSS |
271 #ifdef HAVE_NSS |
| 268 gaim_ssl_set_ops(&ssl_ops); |
272 if (!gaim_ssl_get_ops()) { |
| 269 |
273 gaim_ssl_set_ops(&ssl_ops); |
| |
274 } |
| |
275 |
| |
276 /* Init NSS now, so others can use it even if sslconn never does */ |
| |
277 ssl_nss_init_nss(); |
| 270 return TRUE; |
278 return TRUE; |
| 271 #else |
279 #else |
| 272 return FALSE; |
280 return FALSE; |
| 273 #endif |
281 #endif |
| 274 } |
282 } |
| 275 |
283 |
| 276 static gboolean |
284 static gboolean |
| 277 plugin_unload(GaimPlugin *plugin) |
285 plugin_unload(GaimPlugin *plugin) |
| 278 { |
286 { |
| 279 #ifdef HAVE_NSS |
287 #ifdef HAVE_NSS |
| 280 gaim_ssl_set_ops(NULL); |
288 if (gaim_ssl_get_ops() == &ssl_ops) { |
| |
289 gaim_ssl_set_ops(NULL); |
| |
290 } |
| 281 #endif |
291 #endif |
| 282 |
292 |
| 283 return TRUE; |
293 return TRUE; |
| 284 } |
294 } |
| 285 |
295 |