summaryrefslogtreecommitdiff
path: root/xmlsecurity/source/xmlsec/nss
diff options
context:
space:
mode:
authorJoachim Lingner <jl@openoffice.org>2009-11-23 17:10:39 +0100
committerJoachim Lingner <jl@openoffice.org>2009-11-23 17:10:39 +0100
commit0896dd6ff00761933796beea59187f3d1211becc (patch)
tree4c750e4a5834196b1bbb66ef49054ec21bd4b8ba /xmlsecurity/source/xmlsec/nss
parentcb83dca227b5f2738ef20f66989e5d6708901117 (diff)
jl137: #i107145# improve NSS initialization without profile
Diffstat (limited to 'xmlsecurity/source/xmlsec/nss')
-rw-r--r--xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx82
1 files changed, 35 insertions, 47 deletions
diff --git a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
index f858a5a31421..aa0f29b62e3d 100644
--- a/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
+++ b/xmlsecurity/source/xmlsec/nss/seinitializer_nssimpl.cxx
@@ -203,14 +203,32 @@ bool nsscrypto_initialize( const char* token, bool & out_nss_init )
PR_Init( PR_USER_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- if( NSS_InitReadWrite( token ) != SECSuccess )
+ //token may be an empty string
+ if (token != NULL && strlen(token) > 0)
{
- char * error = NULL;
+ if( NSS_InitReadWrite( token ) != SECSuccess )
+ {
+ xmlsec_trace("Initializing NSS with profile failed.");
+ char * error = NULL;
- PR_GetErrorText(error);
- if (error)
- printf("%s",error);
- return false ;
+ PR_GetErrorText(error);
+ if (error)
+ xmlsec_trace("%s",error);
+ return false ;
+ }
+ }
+ else
+ {
+ xmlsec_trace("Initializing NSS without profile.");
+ if ( NSS_NoDB_Init(NULL) != SECSuccess )
+ {
+ xmlsec_trace("Initializing NSS without profile failed.");
+ char * error = NULL;
+ PR_GetErrorText(error);
+ if (error)
+ xmlsec_trace("%s",error);
+ return false ;
+ }
}
out_nss_init = true;
@@ -317,17 +335,16 @@ bool getMozillaCurrentProfile(
/*
* first, try to get the profile from "MOZILLA_CERTIFICATE_FOLDER"
*/
- char * env = getenv("MOZILLA_CERTIFICATE_FOLDER");
- if (env)
- {
- profilePath = rtl::OUString::createFromAscii( env );
- RTL_LOGFILE_PRODUCT_TRACE1( "XMLSEC: Using env MOZILLA_CERTIFICATE_FOLDER: %s", rtl::OUStringToOString( profilePath, RTL_TEXTENCODING_ASCII_US ).getStr() );
- return true;
- }
- else
- {
- RTL_LOGFILE_TRACE( "getMozillaCurrentProfile: Using MozillaBootstrap..." );
- mozilla::MozillaProductType productTypes[4] = {
+ char * env = getenv("MOZILLA_CERTIFICATE_FOLDER");
+ if (env)
+ {
+ profilePath = rtl::OUString::createFromAscii( env );
+ RTL_LOGFILE_PRODUCT_TRACE1( "XMLSEC: Using env MOZILLA_CERTIFICATE_FOLDER: %s", rtl::OUStringToOString( profilePath, RTL_TEXTENCODING_ASCII_US ).getStr() );
+ return true;
+ }
+ else
+ {
+ mozilla::MozillaProductType productTypes[4] = {
mozilla::MozillaProductType_Thunderbird,
mozilla::MozillaProductType_Mozilla,
mozilla::MozillaProductType_Firefox,
@@ -348,8 +365,6 @@ bool getMozillaCurrentProfile(
{
::rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(productTypes[i]);
- RTL_LOGFILE_TRACE2( "getMozillaCurrentProfile: getDefaultProfile [%i] returns %s", i, rtl::OUStringToOString( profile, RTL_TEXTENCODING_ASCII_US ).getStr() );
-
if (profile != NULL && profile.getLength()>0)
{
profilePath = xMozillaBootstrap->getProfilePath(productTypes[i],profile);
@@ -406,36 +421,9 @@ cssu::Reference< cssxc::XXMLSecurityContext > SAL_CALL
}
- if( !sCertDir.getLength() )
- {
- RTL_LOGFILE_TRACE( "XMLSEC: Error - No certificate directory!" );
- // return NULL;
- }
-
-
- /* Initialize NSPR and NSS */
- /* Replaced with new methods by AF. ----
- //PR_Init( PR_SYSTEM_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
- PR_Init( PR_USER_THREAD, PR_PRIORITY_NORMAL, 1 ) ;
-
- if (NSS_Init(sCertDir.getStr()) != SECSuccess )
- {
- PK11_LogoutAll();
- return NULL;
- }
- ----*/
if( ! *initNSS( sCertDir.getStr() ) )
{
- RTL_LOGFILE_TRACE( "XMLSEC: Error - nsscrypto_initialize() failed." );
- if ( NSS_NoDB_Init(NULL) != SECSuccess )
- {
- RTL_LOGFILE_TRACE( "XMLSEC: NSS_NoDB_Init also failed, NSS Security not available!" );
- return NULL;
- }
- else
- {
- RTL_LOGFILE_TRACE( "XMLSEC: NSS_NoDB_Init works, enough for verifying signatures..." );
- }
+ return NULL;
}
pCertHandle = CERT_GetDefaultCertDB() ;