Skip to Content
0
Former Member
Jan 08, 2008 at 03:51 PM

Problem getting private key

229 Views

Hi all,

I have a problem in loading the private key of my J2EE Engine into an EJB for generation of signatures.

Code snipet:

InitialContext context = new InitialContext();

KeyStoreManager manager = (KeystoreManager) context.lookup("keystore");

KeyStore keyStore = manager.getKeystore(keyStoreView);

SsfProfileKeyStore profile = new SsfProfileKeyStore(keyStore, alias, null);

PrivateKey key = profile.getPrivateKey();

java.security.Signature sig = Signature.getInstance("SHA1withRSA");

sig.initSign(key);

So as I said, I have to do this within an EJB for security reasons. My problem is at the point where the private key is derived from the profile. the getPrivateKey method always returns null.

But if I add a main method to the EJB (senceless I know) and derive the InitialContext remote, it returns the private key and the signature is created.

I also tested to do this with: SsfDataXML and its sign method. If I do this remote, the signature is created. But deploayed as EJB, I get the message:

Private key of signer not available

I checked the permissions within the Security Provider --> XiRuntimePermission and within the Key Storage --> tab Security and gave my deployed EJB the permissions.

Any Ideas?

Thanks

Olli