/[pdpsoft]/branches/nl.nikhef.jgridstart-flyingsaucer/nl.nikhef.jgridstart/src/nl/nikhef/jgridstart/install/certinstall_moz.html
ViewVC logotype

Contents of /branches/nl.nikhef.jgridstart-flyingsaucer/nl.nikhef.jgridstart/src/nl/nikhef/jgridstart/install/certinstall_moz.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1538 - (show annotations) (download)
Fri Mar 5 13:33:08 2010 UTC (11 years, 10 months ago) by wvengen
File MIME type: text/plain
File size: 3617 byte(s)
remove htmltidy message
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
4 <html>
5 <head>
6 <script type="text/javascript">
7 <!--
8 /*
9 * Certificate installation page for Mozilla-based browsers
10 *
11 * This HTML page contains Javascript that installs a PKCS#12 file into
12 * the browser's certificate store. This requires the user to
13 * 1) Grant access to this scripting functionality
14 * 2) Enter the password which protects the PKCS#12 file
15 * A password is required on the PKCS#12 file when it contains a
16 * private key.
17 *
18 * Useful links for development:
19 * - https://developer.mozilla.org/En/XPCOM_API_Reference
20 * - http://kb.mozillazine.org/Development_resources#XPCOM_.2F_XPConnect
21 * - https://developer.mozilla.org/En/Code_snippets/Miscellaneous
22 * - http://mb.eschew.org/16
23 * - http://www.mozilla.org/projects/security/components/signed-scripts.html
24 *
25 * @author wvengen
26 */
27
28 // which PKCS#12 file to import; path relative to this html file
29 var pkcsfile = "import.p12";
30 // whether to close the window when the operation is finished, or no
31 var closeWhenFinished = true;
32
33 function error(msg) {
34 alert("Error while importing certificate:\n"+msg);
35 if (closeWhenFinished) window.close();
36 }
37 function errorhandler(msg, url, line) {
38 error(msg);
39 }
40
41 // returns a File for the absolute filename
42 function getAbsoluteFile(name) {
43 var file = Components.classes["@mozilla.org/file/local;1"].getService(Components.interfaces.nsILocalFile);
44 file.initWithPath(name);
45 return file;
46 }
47
48 // returns a File for the relative filename
49 function getRelativeFile(name) {
50 var ios = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
51 var fh = ios.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
52 var file = fh.getFileFromURLSpec(window.location);
53 file = file.parent;
54 file.append(name);
55 return file;
56 }
57
58 function importcerts() {
59 // request required privileges
60 netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead UniversalXPConnect');
61
62 // it can be quite hard to find the operations of certdb nowadays. Pointer:
63 // http://www.oxymoronical.com/experiments/apidocs/interface/nsIX509CertDB
64 var certdb = Components.classes["@mozilla.org/security/x509certdb;1"].getService(Components.interfaces.nsIX509CertDB);
65
66 // file to import
67 var file = getRelativeFile(pkcsfile);
68
69 // import pkcs12 file, using name from the file
70 certdb.importPKCS12File(null, file);
71
72 /*
73 Some crawling of the mozilla source on mxr.mozilla.org shows that the
74 following functions are called to import a pkcs12 file. This may be
75 useful to know in the future to avoid a password prompt during import.
76
77 importPKCS12File
78 sec_pkcs12_add_key
79 PK11_ImportPrivateKeyInfo (/ PK11_ImportEncryptedPrivateKeyInfo)
80 PK11_ImportPrivateKeyInfoAndReturnKey
81 sec_pkcs12_add_cert
82 PK11_ImportCertForKeyToSlot
83 (or PK11_ImportDERCert for CA cert without key)
84 */
85
86 if (closeWhenFinished) window.close();
87 }
88
89 window.onerror = errorhandler;
90 window.onload = importcerts;
91
92 //-->
93 </script>
94
95 <title></title>
96 </head>
97
98 <body>
99 <h3>Certificate installation page</h3>
100
101 <p>This window can be closed when certificate installation
102 is finished.</p>
103 <noscript>
104 <h4>Whoops</h4>
105
106 <p>You need to enable Javascript to be able to install the
107 certificate.</p>
108 </noscript>
109 </body>
110 </html>
111

Properties

Name Value
svn:mime-type text/plain

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28