mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-04 04:00:17 +01:00
2008-09-05 Dan Williams <dcbw@redhat.com>
* libnm-util/crypto_nss.c libnm-util/crypto_gnutls.c libnm-util/crypto.h - (crypto_init): return error when init fails git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4042 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
814336ec8a
commit
bb6b79a2a6
4 changed files with 29 additions and 3 deletions
|
|
@ -1,3 +1,10 @@
|
|||
2008-09-05 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-util/crypto_nss.c
|
||||
libnm-util/crypto_gnutls.c
|
||||
libnm-util/crypto.h
|
||||
- (crypto_init): return error when init fails
|
||||
|
||||
2008-09-05 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* libnm-glib/nm-device-wifi.c
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
|
||||
enum {
|
||||
NM_CRYPTO_ERR_NONE = 0,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
NM_CRYPTO_ERR_CANT_READ_FILE,
|
||||
NM_CRYPTO_ERR_PEM_FORMAT_INVALID,
|
||||
NM_CRYPTO_ERR_CERT_FORMAT_INVALID,
|
||||
|
|
|
|||
|
|
@ -34,8 +34,16 @@ static guint32 refcount = 0;
|
|||
gboolean
|
||||
crypto_init (GError **error)
|
||||
{
|
||||
if (refcount == 0)
|
||||
gnutls_global_init();
|
||||
if (refcount == 0) {
|
||||
if (gnutls_global_init() != 0) {
|
||||
gnutls_global_deinit();
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
"%s",
|
||||
_("Failed to initialize the crypto engine."));
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
refcount++;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include <pk11pub.h>
|
||||
#include <pkcs11t.h>
|
||||
#include <cert.h>
|
||||
#include <prerror.h>
|
||||
|
||||
#include "crypto.h"
|
||||
|
||||
|
|
@ -38,8 +39,17 @@ gboolean
|
|||
crypto_init (GError **error)
|
||||
{
|
||||
if (refcount == 0) {
|
||||
SECStatus ret;
|
||||
|
||||
PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 1);
|
||||
NSS_NoDB_Init (NULL);
|
||||
ret = NSS_NoDB_Init (NULL);
|
||||
if (ret != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_INIT_FAILED,
|
||||
_("Failed to initialize the crypto engine: %d."),
|
||||
PR_GetError ());
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
refcount++;
|
||||
return TRUE;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue