diff --git a/config/autoconf.mk.in b/config/autoconf.mk.in
index 534460a..b4f638c 100644
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -534,6 +534,9 @@ LIBIDL_CFLAGS = @LIBIDL_CFLAGS@
 LIBIDL_LIBS = @LIBIDL_LIBS@
 STATIC_LIBIDL = @STATIC_LIBIDL@
 
+NSSHELPER_CFLAGS = @NSSHELPER_CFLAGS@
+NSSHELPER_LIBS = @NSSHELPER_LIBS@
+
 MOZ_NATIVE_MAKEDEPEND	= @SYSTEM_MAKEDEPEND@
 
 # Used for LD_LIBRARY_PATH
diff --git a/configure b/configure
index 0b03543..0c902e7 100755
--- a/configure
+++ b/configure
@@ -20335,6 +20335,100 @@ fi
 
 
 
+succeeded=no
+
+if test -z "$PKG_CONFIG"; then
+    # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:20250: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_path_PKG_CONFIG'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  case "$PKG_CONFIG" in
+  /*)
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+  ;;
+  ?:/*)			 
+  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a dos path.
+  ;;
+  *)
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS=":"
+  ac_dummy="$PATH"
+  for ac_dir in $ac_dummy; do 
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$ac_word; then
+      ac_cv_path_PKG_CONFIG="$ac_dir/$ac_word"
+      break
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
+  ;;
+esac
+fi
+PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+if test -n "$PKG_CONFIG"; then
+  echo "$ac_t""$PKG_CONFIG" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+  fi
+
+  if test "$PKG_CONFIG" = "no" ; then
+     echo "*** The pkg-config script could not be found. Make sure it is"
+     echo "*** in your path, or set the PKG_CONFIG environment variable"
+     echo "*** to the full path to pkg-config."
+     echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
+  else
+     PKG_CONFIG_MIN_VERSION=0.9.0
+     if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
+        echo $ac_n "checking for nss-shared-helper""... $ac_c" 1>&6
+echo "configure:20294: checking for nss-shared-helper" >&5
+
+        if $PKG_CONFIG --exists "nss-shared-helper" ; then
+            echo "$ac_t""yes" 1>&6
+            succeeded=yes
+
+            echo $ac_n "checking NSSHELPER_CFLAGS""... $ac_c" 1>&6
+echo "configure:20301: checking NSSHELPER_CFLAGS" >&5
+            NSSHELPER_CFLAGS=`$PKG_CONFIG --cflags "nss-shared-helper"`
+            echo "$ac_t""$NSSHELPER_CFLAGS" 1>&6
+
+            echo $ac_n "checking NSSHELPER_LIBS""... $ac_c" 1>&6
+echo "configure:20306: checking NSSHELPER_LIBS" >&5
+            ## Remove evil flags like -Wl,--export-dynamic
+            NSSHELPER_LIBS="`$PKG_CONFIG --libs \"nss-shared-helper\" |sed s/-Wl,--export-dynamic//g`"
+            echo "$ac_t""$NSSHELPER_LIBS" 1>&6
+        else
+            NSSHELPER_CFLAGS=""
+            NSSHELPER_LIBS=""
+            ## If we have a custom action on failure, don't print errors, but 
+            ## do set a variable so people can do so.
+            NSSHELPER_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "nss-shared-helper"`
+            echo $NSSHELPER_PKG_ERRORS
+        fi
+
+        
+        
+     else
+        echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
+        echo "*** See http://www.freedesktop.org/software/pkgconfig"
+     fi
+  fi
+
+  if test $succeeded = yes; then
+     :
+  else
+     if test "$COMPILE_ENVIRONMENT"; then 
+       { echo "configure: error: Library requirements (nss-shared-helper) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them." 1>&2; exit 1; }
+     fi
+  fi
+
+
+
+
 
 
 # Check whether --enable-xul or --disable-xul was given.
@@ -21641,6 +21735,8 @@ s%@MOZ_CAIRO_LIBS@%$MOZ_CAIRO_LIBS%g
 s%@LCMS_CFLAGS@%$LCMS_CFLAGS%g
 s%@LCMS_LIBS@%$LCMS_LIBS%g
 s%@MOZ_NATIVE_LCMS@%$MOZ_NATIVE_LCMS%g
+s%@NSSHELPER_CFLAGS@%$NSSHELPER_CFLAGS%g
+s%@NSSHELPER_LIBS@%$NSSHELPER_LIBS%g
 s%@MOZ_XUL@%$MOZ_XUL%g
 s%@MOZ_PYTHON_EXTENSIONS@%$MOZ_PYTHON_EXTENSIONS%g
 s%@MOZ_PYTHON@%$MOZ_PYTHON%g
diff --git a/configure.in b/configure.in
index bc72aff..8968a4a 100644
--- a/configure.in
+++ b/configure.in
@@ -7451,6 +7451,15 @@ AC_SUBST(LCMS_CFLAGS)
 AC_SUBST(LCMS_LIBS)
 
 dnl ========================================================
+dnl Check for nss-shared-helper
+dnl ========================================================
+
+PKG_CHECK_MODULES(NSSHELPER, nss-shared-helper)
+
+AC_SUBST(NSSHELPER_CFLAGS)
+AC_SUBST(NSSHELPER_LIBS)
+
+dnl ========================================================
 dnl disable xul
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(xul,
diff --git a/security/manager/ssl/src/Makefile.in b/security/manager/ssl/src/Makefile.in
index 031be55..c673e46 100644
--- a/security/manager/ssl/src/Makefile.in
+++ b/security/manager/ssl/src/Makefile.in
@@ -139,12 +139,13 @@ DEFINES += -DNSS_ENABLE_ECC
 
 # Use local includes because they are inserted before INCLUDES
 # so that Mozilla's nss.h is used, not glibc's
-LOCAL_INCLUDES += $(NSS_CFLAGS)
+LOCAL_INCLUDES += $(NSS_CFLAGS) $(NSSHELPER_CFLAGS)
 
 EXTRA_DSO_LDOPTS += \
 		$(MOZ_UNICHARUTIL_LIBS) \
 		$(MOZ_COMPONENT_LIBS) \
 		$(MOZ_JS_LIBS) \
+		$(NSSHELPER_LIBS) \
 		$(NSS_LIBS) \
 		$(NULL)
 
diff --git a/security/manager/ssl/src/nsNSSComponent.cpp b/security/manager/ssl/src/nsNSSComponent.cpp
index 45adcb9..925fd8d 100644
--- a/security/manager/ssl/src/nsNSSComponent.cpp
+++ b/security/manager/ssl/src/nsNSSComponent.cpp
@@ -44,6 +44,10 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
+#pragma GCC visibility push(default)
+#include <nss-shared-helper.h>
+#pragma GCC visibility pop
+
 #include "nsNSSComponent.h"
 #include "nsNSSCallbacks.h"
 #include "nsNSSIOLayer.h"
@@ -1545,7 +1549,12 @@ nsNSSComponent::InitializeNSS(PRBool showWarningBox)
 
     ConfigureInternalPKCS11Token();
 
-    SECStatus init_rv = ::NSS_InitReadWrite(profileStr.get());
+    SECStatus init_rv = ::nsshelp_open_db ("mozilla-xul", profileStr.get(), 0);
+
+    if (init_rv != SECSuccess) {
+      PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("can not init NSS using nsshelp_open_db in %s\n", profileStr.get()));
+      init_rv = ::NSS_InitReadWrite(profileStr.get());
+    }
 
     if (init_rv != SECSuccess) {
       PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("can not init NSS r/w in %s\n", profileStr.get()));
diff --git a/toolkit/library/Makefile.in b/toolkit/library/Makefile.in
index 7b00f11..6aed115 100644
--- a/toolkit/library/Makefile.in
+++ b/toolkit/library/Makefile.in
@@ -201,7 +201,7 @@ endif
 
 DEFINES += -DIMPL_XREAPI
 
-EXTRA_DSO_LDOPTS += $(NSPR_LIBS)
+EXTRA_DSO_LDOPTS += $(NSPR_LIBS) $(NSSHELPER_LIBS)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
 CXXFLAGS	+= $(TK_CFLAGS)
