OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // Custom binding for the webRequest API. |
| 6 |
| 7 var binding = require('binding').Binding.create('enterprise.certificates'); |
| 8 var certificatesInternal = |
| 9 require('binding') |
| 10 .Binding.create('enterprise.certificatesInternal') |
| 11 .generate(); |
| 12 // var sendRequest = require('sendRequest').sendRequest; |
| 13 var getPrivateKeyNative = |
| 14 requireNative('enterprise_certificates_natives').GetPrivateKey; |
| 15 |
| 16 binding.registerCustomHook(function(api) { |
| 17 var apiFunctions = api.apiFunctions; |
| 18 |
| 19 var keyFormat = 'pkcs8'; |
| 20 var ret = apiFunctions.setHandleRequest('importClientCertificate', |
| 21 function(key, cert, token, callback) { |
| 22 console.log('Try native export'); |
| 23 var rawKey = new Uint8Array(getPrivateKeyNative(key)).buffer; |
| 24 try { |
| 25 certificatesInternal.importClientCertificate( |
| 26 rawKey, cert, token, callback); |
| 27 } |
| 28 catch (e) { |
| 29 console.log('catched error: ' + e); |
| 30 } |
| 31 return true; |
| 32 }); |
| 33 console.log(ret); |
| 34 }); |
| 35 |
| 36 exports.binding = binding.generate(); |
OLD | NEW |