diff --git a/atom/browser/api/atom_api_app.cc b/atom/browser/api/atom_api_app.cc index 46402d7f9b28..9d0aa792e607 100644 --- a/atom/browser/api/atom_api_app.cc +++ b/atom/browser/api/atom_api_app.cc @@ -167,7 +167,7 @@ int ImportIntoCertStore( base::string16 password; net::CertificateList imported_certs; int rv = -1; - options.GetString("clientCertificate", &cert_path); + options.GetString("certificate", &cert_path); options.GetString("password", &password); if (!cert_path.empty()) { @@ -405,7 +405,7 @@ bool App::MakeSingleInstance( } #if defined(USE_NSS_CERTS) -void App::ImportClientCertificate( +void App::ImportCertificate( const base::DictionaryValue& options, const net::CompletionCallback& callback) { auto browser_context = AtomBrowserMainParts::Get()->browser_context(); @@ -474,7 +474,7 @@ mate::ObjectTemplateBuilder App::GetObjectTemplateBuilder( &App::AllowNTLMCredentialsForAllDomains) .SetMethod("getLocale", &App::GetLocale) #if defined(USE_NSS_CERTS) - .SetMethod("importClientCertificate", &App::ImportClientCertificate) + .SetMethod("importCertificate", &App::ImportCertificate) #endif .SetMethod("makeSingleInstance", &App::MakeSingleInstance); } diff --git a/atom/browser/api/atom_api_app.h b/atom/browser/api/atom_api_app.h index acaa64a3437e..d4102521c0b4 100644 --- a/atom/browser/api/atom_api_app.h +++ b/atom/browser/api/atom_api_app.h @@ -111,8 +111,8 @@ class App : public AtomBrowserClient::Delegate, std::string GetLocale(); #if defined(USE_NSS_CERTS) - void ImportClientCertificate(const base::DictionaryValue& options, - const net::CompletionCallback& callback); + void ImportCertificate(const base::DictionaryValue& options, + const net::CompletionCallback& callback); #endif #if defined(OS_WIN) diff --git a/docs/api/app.md b/docs/api/app.md index 84eeed51d6cc..c8ddb47bd315 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -514,6 +514,18 @@ if (browserOptions.transparent) { This method returns `true` if the system is in Dark Mode, and `false` otherwise. +### `app.importCertificate(options, callback)` _LINUX_ + +* `options` Object + * `certificate` String - Path for the pkcs12 file. + * `password` String - Passphrase for the certificate. +* `callback` Function + * `result` Integer - Result of import. + +Imports the certificate in pkcs12 format into the platform certificate store. +`callback` is called with the `result` of import operation, a value of `0` indicates +success while any other value indicates failure according to chromium [net_error_list](https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h). + ### `app.commandLine.appendSwitch(switch[, value])` Append a switch (with optional `value`) to Chromium's command line. diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index 8923d2d214fa..1c20ef8e4523 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -89,7 +89,7 @@ describe('app module', function () { }) }) - describe('app.importClientCertificate', function () { + describe('app.importCertificate', function () { if (process.platform !== 'linux') return @@ -124,7 +124,7 @@ describe('app module', function () { it('can import certificate into platform cert store', function (done) { let options = { - clientCertificate: path.join(certPath, 'client.p12'), + certificate: path.join(certPath, 'client.p12'), password: 'electron' } @@ -143,7 +143,7 @@ describe('app module', function () { callback(list[0]) }) - app.importClientCertificate(options, function (result) { + app.importCertificate(options, function (result) { assert(!result) server.listen(0, '127.0.0.1', function () { var port = server.address().port