Add password error hint when adding new cert.
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 0aa74aa..c891979 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1990,12 +1990,12 @@
     <string name="cstor_password_verification_error">Please enter the password again. The password must have at least 8 characters and must not contain spaces.</string>
     <string name="cstor_name_empty_error">Please enter a name.</string>
     <string name="cstor_name_char_error">Please enter a name that contains only letters and numbers.</string>
+    <string name="cstor_storage_error">Unable to save the certificate. Click OK to retry.</string>
 
     <!-- toast message -->
     <string name="cstor_is_enabled">Credential storage is enabled.</string>
     <!-- toast message -->
     <string name="cstor_is_added">%s is added.</string>
-    <string name="cstor_add_error">Failed to add %s.</string>
 
     <!-- Sound settings screen, setting check box label -->
     <string name="emergency_tone_title">Emergency tone</string>
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 4947c2b..63d88d3 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -516,16 +516,6 @@
             mAccessCheckBox.setChecked(false);
         }
 
-        private void addCredential() {
-            String formatString = mCstorAddCredentialHelper.saveToStorage() < 0
-                    ? getString(R.string.cstor_add_error)
-                    : getString(R.string.cstor_is_added);
-            String message = String.format(formatString,
-                    mCstorAddCredentialHelper.getName());
-            Toast.makeText(SecuritySettings.this, message, Toast.LENGTH_SHORT)
-                    .show();
-        }
-
         public void onCancel(DialogInterface dialog) {
             if (mCstorAddCredentialHelper != null) {
                 // release the object here so that it doesn't get triggerred in
@@ -578,7 +568,12 @@
                     } else if (!isCstorUnlocked()) {
                         showDialog(CSTOR_UNLOCK_DIALOG);
                     } else {
-                        addCredential();
+                        String formatString =
+                                getString(R.string.cstor_is_added);
+                        String message = String.format(formatString,
+                                mCstorAddCredentialHelper.getName());
+                        Toast.makeText(SecuritySettings.this, message,
+                                Toast.LENGTH_SHORT).show();
                         finish();
                     }
                 } else if (mSpecialIntent != null) {
@@ -630,6 +625,15 @@
                 mCstorAddCredentialHelper.setPassword(password);
             }
 
+            if (mCstorAddCredentialHelper.saveToStorage() < 0) {
+                if (mCstorAddCredentialHelper.isPkcs12Keystore()) {
+                    showError(R.string.cstor_password_error);
+                } else {
+                    showError(R.string.cstor_storage_error);
+                }
+                return false;
+            }
+
             return true;
         }