Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Unified Diff: chrome/browser/dom_ui/options/certificate_manager_handler.cc

Issue 5686002: NSS: PKCS 11 password prompt. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing review comments Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/dom_ui/options/certificate_manager_handler.cc
diff --git a/chrome/browser/dom_ui/options/certificate_manager_handler.cc b/chrome/browser/dom_ui/options/certificate_manager_handler.cc
index 480fcb4a3cd7460c8ca28f66d7666bd330ea477f..68a76851967a88142563a5a7b215f280041d2ec1 100644
--- a/chrome/browser/dom_ui/options/certificate_manager_handler.cc
+++ b/chrome/browser/dom_ui/options/certificate_manager_handler.cc
@@ -17,7 +17,9 @@
#include "chrome/browser/gtk/certificate_dialogs.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
+#include "chrome/browser/ui/pk11_password_dialog.h"
#include "grit/generated_resources.h"
+#include "net/base/crypto_module.h"
#include "net/base/x509_certificate.h"
namespace {
@@ -527,6 +529,21 @@ void CertificateManagerHandler::ExportPersonalPasswordSelected(
ImportExportCleanup();
return;
}
+
+ // Currently, we don't support exporting more than one at a time. If we do,
+ // this would need some cleanup to handle unlocking multiple slots.
+ DCHECK_EQ(selected_cert_list_.size(), 1U);
+
+ // TODO(mattm): do something smarter about non-extractable keys
+ browser::UnlockCertSlotIfNecessary(
+ selected_cert_list_[0].get(),
+ browser::kPK11PasswordCertExport,
+ "", // unused.
+ NewCallback(this,
+ &CertificateManagerHandler::ExportPersonalSlotsUnlocked));
+}
+
+void CertificateManagerHandler::ExportPersonalSlotsUnlocked() {
std::string output;
int num_exported = certificate_manager_model_->cert_db().ExportToPKCS12(
selected_cert_list_,
@@ -605,7 +622,23 @@ void CertificateManagerHandler::ImportPersonalFileRead(
UTF8ToUTF16(safe_strerror(read_errno))));
return;
}
- int result = certificate_manager_model_->ImportFromPKCS12(data, password_);
+
+ file_data_ = data;
+
+ // TODO(mattm): allow user to choose a slot to import to.
+ module_ = certificate_manager_model_->cert_db().GetDefaultModule();
+
+ browser::UnlockSlotIfNecessary(
+ module_.get(),
+ browser::kPK11PasswordCertImport,
+ "", // unused.
+ NewCallback(this,
+ &CertificateManagerHandler::ImportPersonalSlotUnlocked));
+}
+
+void CertificateManagerHandler::ImportPersonalSlotUnlocked() {
+ int result = certificate_manager_model_->ImportFromPKCS12(
+ module_, file_data_, password_);
ImportExportCleanup();
dom_ui_->CallJavascriptFunction(L"CertificateRestoreOverlay.dismiss");
switch (result) {
@@ -634,8 +667,10 @@ void CertificateManagerHandler::CancelImportExportProcess(
void CertificateManagerHandler::ImportExportCleanup() {
file_path_.clear();
password_.clear();
+ file_data_.clear();
selected_cert_list_.clear();
select_file_dialog_ = NULL;
+ module_ = NULL;
}
void CertificateManagerHandler::ImportServer(const ListValue* args) {
« no previous file with comments | « chrome/browser/dom_ui/options/certificate_manager_handler.h ('k') | chrome/browser/gtk/pk11_password_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698