/    Sign up×
Community /Pin to ProfileBookmark

Automatic Loading of Security Module in Firefox

Hi There!

I am new to javascript and I cant make a code work.

I am trying to automatically load a security module in firefox and found this code on the internet:

[code=html]
<head><title>This is an example page</title></head>
<body>
<script type=”text/javascript”>
<!–
const nsIPKCS11 = Components.interfaces.nsIPKCS11;
const nsPKCS11ContractID = “@mozilla.org/security/pkcs11;1”;
const p11path = [some path]
try{
var PKCS11 = Components.classes[nsPKCS11ContractID].getService(nsIPKCS11);
PKCS11.addModule(“ACS PKCS#11 Module”, p11path, 0, 0);
}catch(e){
alert(e);
}
//–>
</script>
</body>
[/code]

From the code above, I am getting an error:

[QUOTE]

“Error: Permission denied to access property ‘classes'”

[/QUOTE]

So I searched the net again for this error and found that I have to enable privilege before I call the classes property. But when I added this line before the calling of the classes property:

[QUOTE]

netscape.security.PrivilegeManager.enablePrivilege(‘UniversalXPConnect’);

[/QUOTE]

I got a new error stating:

[QUOTE]

“TypeError netscape.security.PrivilegeManager is undefined”

[/QUOTE]

Please help!
Thanks!

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @to_its9 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...