Here is the code I use to pick up certificate :
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var cert;
var picker =
Components.classes["@mozilla.org/user_cert_picker;1"].createInstance(Components.interfaces.nsIUserCertPicker);
var canceled = {value:0};
cert = picker.pickByUsage(window,"",4,false, false, canceled);
alert(cert.nickname);
But this code works only when the code is loaded from the local
filesystem.
To use the code for a web application you need to sign the javascript
with signtool 1.3. But I can't do that despite my efforts...
Anyone can do that???
Thanks,
Rodrigue
Scott Rea <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> Rodrigue,
>
> This is great - thanks for the info/link!
>
> Does anyone have any examples of how I can use JavaScript to invoke
> certificate dialogs now?
> e.g. the following JavaScript doesn't work - did I miss something somewhere?
>
> function TestMe() {
>
> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
> var cmgr =
> Components.classes["@mozilla.org/nsCertificateDialogs;1"].getService();
> cmgr = cmgr.QueryInterface(Components.interfaces.nsICertPickDialogs);
> var Ir =
> Components.classes["@mozilla.org/dom/window-controller;1"].getService();
> Ir = Ir.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
> var Intf =
> Ir.getInterface("{51d59b08-1dd2-11b2-ad4a-a51b92f8a184}",Intf);
> var cert;
> cmgr.PickCertificate(Intf,"","",1,cert,"","");
> }
>
> My error message is about the var Intf=...line :
>
> Error: uncaught exception: [Exception... "Could not convert JavaScript
> argument arg 0 [nsIInterfaceRequestor.getInterface]" nsresult:
> "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame ::
> testjs.html :: TestMe :: line 12" data: no]
>
> Regards,
>
> -Scott
>
> Rodrigue Butaye wrote:
>
> >I think it's a base component, but I'm not sure.
> >The references are :
> >Contract ID - @mozilla.org/security/x509certdb;1
> >Class ID - {da48b3c0-1284-11d5-ac67-000064657374}
> >
> >You can verify that's available on a specific version of browser with
> >the XPCOM component viewer available at :
> >http://www.hacksrus.com/~ginda/cview/
> >
> >Once the component viewer is installed, you can access the api of the
> >component by right clicking on the interface of the component.(to use
> >the component viewer : Tools--> web development--> component viewer)
> >
> >I hope it will help you,
> >
> >Rodrigue Butaye
> >
> >
> >Scott Rea <[EMAIL PROTECTED]> wrote in message news:<[EMAIL PROTECTED]>...
> >
> >
> >>I am looking for a way to automate key recovery for end entity
> >>certificates in Netscape/Mozilla browsers with the P12 blob coming down
> >>from a server. Seems an XPCOM component scripted via JavaScript may do
> >>the trick - or am I better off trying this via JSS?
> >>
> >>Has anyone tried this yet?
> >>
> >>I am new - any help/pointers would be most appreciated.
> >>
> >>I saw a post from Rodrigue Butaye ([EMAIL PROTECTED]) a fews days back
> >>about a x509certdb component but cannot discover what it refers to - any
> >>information of readily available components in pre-built binaries would
> >>be fantastic.
> >>
> >>Regards
> >>
> >>-Scott
> >>
> >>