Quantcast

please help: Unknown CMS exception

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

please help: Unknown CMS exception

Munteanu Andrei

Hello.

I am working to make a java applet work on Linux. I am not sure if the applet
ever worked on any system....

I have this error i am fighting with since Thursday. Notice the "Caused by:
java.security.SignatureException: java.lang.NullPointerException" at the end.

Do you know what could be null?


Here is the code:

                CMSSignedData signedData = null;
                try {
                        signedData = signGen.generate(content, true,
BouncyCastleProvider.PROVIDER_NAME);
                        return signedData.getEncoded();
                } catch (NoSuchAlgorithmException e) {
                        LOGGER.fatal("Unable to find selected algorithm  (" + e + ")", e);
                } catch (NoSuchProviderException e) {
                        LOGGER.fatal("Unable to find cryptographic provider (" + e + ")", e);
                } catch (CMSException e) {
                        LOGGER.fatal("Unknown CMS exception2 (" + e + ")", e);
                } catch (IOException e) {
                        LOGGER.fatal("Unable to read file (" + e + ")", e);
                }


The problem is basically the call:

signGen.generate(content, true, BouncyCastleProvider.PROVIDER_NAME);


The only variables are content and signGen. content seems to be not empty, and
signGen seems to be well constructed as well. I haven't yet tested the
certificate used to construct signGen, but at least i tested it is not null.

However, if i call it this way:

signGen.generate(content, true, null);

....there is no error at all!!!!!!!! Do you have any idea what causes
this "unknown error"?

Please ask me if you need more information...


107  [AWT-EventQueue-2] FATAL org.linagora.mpe.applet.sign.BCSigner  - Unknown
CMS exception2 (org.bouncycastle.cms.CMSException: error creating signature.)
org.bouncycastle.cms.CMSException: error creating signature.
        at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
        at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
        at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
        at org.linagora.mpe.applet.sign.BCSigner.signerBC(Unknown Source)
        at org.linagora.mpe.applet.sign.Signer.signe(Unknown Source)
        at org.linagora.mpe.applet.sign.Action.signer(Unknown Source)
        at org.linagora.mpe.applet.PrincipalPanel.actionPerformed(Unknown Source)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
        at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
        at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
        at
javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
        at java.awt.Component.processMouseEvent(Component.java:5501)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
        at java.awt.Component.processEvent(Component.java:5266)
        at java.awt.Container.processEvent(Container.java:1966)
        at java.awt.Component.dispatchEventImpl(Component.java:3968)
        at java.awt.Container.dispatchEventImpl(Container.java:2024)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
        at java.awt.Container.dispatchEventImpl(Container.java:2010)
        at java.awt.Component.dispatchEvent(Component.java:3803)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
        at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Caused by: java.security.SignatureException: java.lang.NullPointerException
        at org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(Unknown
Source)
        at java.security.Signature.sign(Signature.java:527)
        at org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(Unknown
Source)
        ... 30 more


--
moa3333


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: please help: Unknown CMS exception

David Hook-4

What's going into the signers being added to the CMSSignedDataGenerator?

Regards,

David

On Fri, 2007-06-22 at 09:56 +0200, Andrei Munteanu wrote:

> Hello.
>
> I am working to make a java applet work on Linux. I am not sure if the applet
> ever worked on any system....
>
> I have this error i am fighting with since Thursday. Notice the "Caused by:
> java.security.SignatureException: java.lang.NullPointerException" at the end.
>
> Do you know what could be null?
>
>
> Here is the code:
>
> CMSSignedData signedData = null;
> try {
> signedData = signGen.generate(content, true,
> BouncyCastleProvider.PROVIDER_NAME);
> return signedData.getEncoded();
> } catch (NoSuchAlgorithmException e) {
> LOGGER.fatal("Unable to find selected algorithm  (" + e + ")", e);
> } catch (NoSuchProviderException e) {
> LOGGER.fatal("Unable to find cryptographic provider (" + e + ")", e);
> } catch (CMSException e) {
> LOGGER.fatal("Unknown CMS exception2 (" + e + ")", e);
> } catch (IOException e) {
> LOGGER.fatal("Unable to read file (" + e + ")", e);
> }
>
>
> The problem is basically the call:
>
> signGen.generate(content, true, BouncyCastleProvider.PROVIDER_NAME);
>
>
> The only variables are content and signGen. content seems to be not empty, and
> signGen seems to be well constructed as well. I haven't yet tested the
> certificate used to construct signGen, but at least i tested it is not null.
>
> However, if i call it this way:
>
> signGen.generate(content, true, null);
>
> ....there is no error at all!!!!!!!! Do you have any idea what causes
> this "unknown error"?
>
> Please ask me if you need more information...
>
>
> 107  [AWT-EventQueue-2] FATAL org.linagora.mpe.applet.sign.BCSigner  - Unknown
> CMS exception2 (org.bouncycastle.cms.CMSException: error creating signature.)
> org.bouncycastle.cms.CMSException: error creating signature.
> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> at org.linagora.mpe.applet.sign.BCSigner.signerBC(Unknown Source)
> at org.linagora.mpe.applet.sign.Signer.signe(Unknown Source)
> at org.linagora.mpe.applet.sign.Action.signer(Unknown Source)
> at org.linagora.mpe.applet.PrincipalPanel.actionPerformed(Unknown Source)
> at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
> at
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
> at
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
> at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> at
> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> at java.awt.Component.processMouseEvent(Component.java:5501)
> at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
> at java.awt.Component.processEvent(Component.java:5266)
> at java.awt.Container.processEvent(Container.java:1966)
> at java.awt.Component.dispatchEventImpl(Component.java:3968)
> at java.awt.Container.dispatchEventImpl(Container.java:2024)
> at java.awt.Component.dispatchEvent(Component.java:3803)
> at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
> at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
> at java.awt.Container.dispatchEventImpl(Container.java:2010)
> at java.awt.Component.dispatchEvent(Component.java:3803)
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> at
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
> at
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> Caused by: java.security.SignatureException: java.lang.NullPointerException
> at org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(Unknown
> Source)
> at java.security.Signature.sign(Signature.java:527)
> at org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(Unknown
> Source)
> ... 30 more
>
>
> --
> moa3333
>
>
>


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: please help: Unknown CMS exception

Munteanu Andrei
Le Friday 22 June 2007 13:46:29 David Hook a écrit:
> What's going into the signers being added to the CMSSignedDataGenerator?
>
> Regards,
>
> David
>


signGen.addSigner(privateKey,userCertificate,CMSSignedDataGenerator.DIGEST_SHA1);

signGen.addCertificatesAndCRLs(certs);

i checked that privateKey and userCertificate are not null values

certs = CertStore.getInstance("Collection", new
CollectionCertStoreParameters(certList),BouncyCastleProvider.PROVIDER_NAME);

certList is en ArrayList with one certificate inside:

certList.add(userCertificate);



thanks for helping.

Andrei


> On Fri, 2007-06-22 at 09:56 +0200, Andrei Munteanu wrote:
> > Hello.
> >
> > I am working to make a java applet work on Linux. I am not sure if the
> > applet ever worked on any system....
> >
> > I have this error i am fighting with since Thursday. Notice the "Caused
> > by: java.security.SignatureException: java.lang.NullPointerException" at
> > the end.
> >
> > Do you know what could be null?
> >
> >
> > Here is the code:
> >
> > CMSSignedData signedData = null;
> > try {
> > signedData = signGen.generate(content, true,
> > BouncyCastleProvider.PROVIDER_NAME);
> > return signedData.getEncoded();
> > } catch (NoSuchAlgorithmException e) {
> > LOGGER.fatal("Unable to find selected algorithm  (" + e + ")", e);
> > } catch (NoSuchProviderException e) {
> > LOGGER.fatal("Unable to find cryptographic provider (" + e + ")", e);
> > } catch (CMSException e) {
> > LOGGER.fatal("Unknown CMS exception2 (" + e + ")", e);
> > } catch (IOException e) {
> > LOGGER.fatal("Unable to read file (" + e + ")", e);
> > }
> >
> >
> > The problem is basically the call:
> >
> > signGen.generate(content, true, BouncyCastleProvider.PROVIDER_NAME);
> >
> >
> > The only variables are content and signGen. content seems to be not
> > empty, and signGen seems to be well constructed as well. I haven't yet
> > tested the certificate used to construct signGen, but at least i tested
> > it is not null.
> >
> > However, if i call it this way:
> >
> > signGen.generate(content, true, null);
> >
> > ....there is no error at all!!!!!!!! Do you have any idea what causes
> > this "unknown error"?
> >
> > Please ask me if you need more information...
> >
> >
> > 107  [AWT-EventQueue-2] FATAL org.linagora.mpe.applet.sign.BCSigner  -
> > Unknown CMS exception2 (org.bouncycastle.cms.CMSException: error creating
> > signature.) org.bouncycastle.cms.CMSException: error creating signature.
> > at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> > at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> > at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> > at org.linagora.mpe.applet.sign.BCSigner.signerBC(Unknown Source)
> > at org.linagora.mpe.applet.sign.Signer.signe(Unknown Source)
> > at org.linagora.mpe.applet.sign.Action.signer(Unknown Source)
> > at org.linagora.mpe.applet.PrincipalPanel.actionPerformed(Unknown
> > Source) at
> > javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
> > at
> > javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:21
> >69) at
> > javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.jav
> >a:420) at
> > javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258) at
> > javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListe
> >ner.java:236) at java.awt.Component.processMouseEvent(Component.java:5501)
> > at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
> > at java.awt.Component.processEvent(Component.java:5266)
> > at java.awt.Container.processEvent(Container.java:1966)
> > at java.awt.Component.dispatchEventImpl(Component.java:3968)
> > at java.awt.Container.dispatchEventImpl(Container.java:2024)
> > at java.awt.Component.dispatchEvent(Component.java:3803)
> > at
> > java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212) at
> > java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892) at
> > java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822) at
> > java.awt.Container.dispatchEventImpl(Container.java:2010)
> > at java.awt.Component.dispatchEvent(Component.java:3803)
> > at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> > at
> > java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread
> >.java:242) at
> > java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.j
> >ava:163) at
> > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at
> > java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at
> > java.awt.EventDispatchThread.run(EventDispatchThread.java:110) Caused by:
> > java.security.SignatureException: java.lang.NullPointerException at
> > org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(Unknown
> > Source)
> > at java.security.Signature.sign(Signature.java:527)
> > at
> > org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(Unknow
> >n Source)
> > ... 30 more
> >
> >
> > --
> > moa3333



--
moa3333

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: please help: Unknown CMS exception

Munteanu Andrei
In reply to this post by David Hook-4

Hello again,

i have some news about this error. I can't debug it but i've recompiled BC
libraries from source and aded some printStackTraces and manual check of
values.

I found the source of the problem.

it is in the file (from last release 137):

org.bouncycastle.crypto.engines.RSACoreEngine;

Here is the modified code:

    public int getInputBlockSize()
    {

        int bitSize = 0;
        try{
            if (key == null)
            {
                System.out.println("key is null!");
            }
            if (key.getModulus() == null)
            {
                System.out.println("key.getModulus() is null!");
                   //***************-------here is the error
                   //***************-------here is the error
                   //***************-------here is the error
                   //***************-------here is the error
            }
            bitSize = key.getModulus().bitLength();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        if (forEncryption)
        {
            return (bitSize + 7) / 8 - 1;
        }
        else
        {
            return (bitSize + 7) / 8;
        }
    }


Here is the output:


key.getModulus() is null!
java.lang.NullPointerException
        at
org.bouncycastle.crypto.engines.RSACoreEngine.getInputBlockSize(RSACoreEngine.java:63)
        at
org.bouncycastle.crypto.engines.RSABlindedEngine.getInputBlockSize(RSABlindedEngine.java:60)
        at
org.bouncycastle.crypto.encodings.PKCS1Encoding.encodeBlock(PKCS1Encoding.java:137)
        at
org.bouncycastle.crypto.encodings.PKCS1Encoding.processBlock(PKCS1Encoding.java:123)
        at
org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(JDKDigestSignature.java:138)
        at java.security.Signature.sign(Signature.java:527)
        at
org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(CMSSignedDataGenerator.java:267)
        at
org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:464)
        at
org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:398)
        at
org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:548)
        at org.linagora.mpe.applet.sign.BCSigner.signerBC(BCSigner.java:209)
.......................



Best regards.


>
> What's going into the signers being added to the CMSSignedDataGenerator?
>
> Regards,
>
> David
>
> On Fri, 2007-06-22 at 09:56 +0200, Andrei Munteanu wrote:
>> Hello.
>>
>> I am working to make a java applet work on Linux. I am not sure if the
>> applet
>> ever worked on any system....
>>
>> I have this error i am fighting with since Thursday. Notice the "Caused
>> by:
>> java.security.SignatureException: java.lang.NullPointerException" at the
>> end.
>>
>> Do you know what could be null?
>>
>>
>> Here is the code:
>>
>> CMSSignedData signedData = null;
>> try {
>> signedData = signGen.generate(content, true,
>> BouncyCastleProvider.PROVIDER_NAME);
>> return signedData.getEncoded();
>> } catch (NoSuchAlgorithmException e) {
>> LOGGER.fatal("Unable to find selected algorithm  (" + e + ")", e);
>> } catch (NoSuchProviderException e) {
>> LOGGER.fatal("Unable to find cryptographic provider (" + e + ")", e);
>> } catch (CMSException e) {
>> LOGGER.fatal("Unknown CMS exception2 (" + e + ")", e);
>> } catch (IOException e) {
>> LOGGER.fatal("Unable to read file (" + e + ")", e);
>> }
>>
>>
>> The problem is basically the call:
>>
>> signGen.generate(content, true, BouncyCastleProvider.PROVIDER_NAME);
>>
>>
>> The only variables are content and signGen. content seems to be not
>> empty, and
>> signGen seems to be well constructed as well. I haven't yet tested the
>> certificate used to construct signGen, but at least i tested it is not
>> null.
>>
>> However, if i call it this way:
>>
>> signGen.generate(content, true, null);
>>
>> ....there is no error at all!!!!!!!! Do you have any idea what causes
>> this "unknown error"?
>>
>> Please ask me if you need more information...
>>
>>
>> 107  [AWT-EventQueue-2] FATAL org.linagora.mpe.applet.sign.BCSigner  -
>> Unknown
>> CMS exception2 (org.bouncycastle.cms.CMSException: error creating
>> signature.)
>> org.bouncycastle.cms.CMSException: error creating signature.
>> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
>> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
>> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
>> at org.linagora.mpe.applet.sign.BCSigner.signerBC(Unknown Source)
>> at org.linagora.mpe.applet.sign.Signer.signe(Unknown Source)
>> at org.linagora.mpe.applet.sign.Action.signer(Unknown Source)
>> at org.linagora.mpe.applet.PrincipalPanel.actionPerformed(Unknown
>> Source)
>> at
>> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
>> at
>> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
>> at
>> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
>> at
>> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
>> at
>> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
>> at java.awt.Component.processMouseEvent(Component.java:5501)
>> at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
>> at java.awt.Component.processEvent(Component.java:5266)
>> at java.awt.Container.processEvent(Container.java:1966)
>> at java.awt.Component.dispatchEventImpl(Component.java:3968)
>> at java.awt.Container.dispatchEventImpl(Container.java:2024)
>> at java.awt.Component.dispatchEvent(Component.java:3803)
>> at
>> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
>> at
>> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
>> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
>> at java.awt.Container.dispatchEventImpl(Container.java:2010)
>> at java.awt.Component.dispatchEvent(Component.java:3803)
>> at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
>> at
>> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
>> at
>> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
>> at
>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
>> at
>> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
>> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
>> Caused by: java.security.SignatureException:
>> java.lang.NullPointerException
>> at org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(Unknown
>> Source)
>> at java.security.Signature.sign(Signature.java:527)
>> at
>> org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(Unknown
>> Source)
>> ... 30 more
>>
>>
>> --
>> moa3333
>>
>>
>>
>
>
>



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: please help: Unknown CMS exception

David Hook-4

That indicates that the private key you are using is in some way
corrupted. The modulus of an RSA key cannot be null.

Regards,

David

On Fri, 2007-06-22 at 23:16 +0200, Olimpiu Andrei Munteanu wrote:

> Hello again,
>
> i have some news about this error. I can't debug it but i've recompiled BC
> libraries from source and aded some printStackTraces and manual check of
> values.
>
> I found the source of the problem.
>
> it is in the file (from last release 137):
>
> org.bouncycastle.crypto.engines.RSACoreEngine;
>
> Here is the modified code:
>
>     public int getInputBlockSize()
>     {
>
>         int bitSize = 0;
>         try{
>             if (key == null)
>             {
>                 System.out.println("key is null!");
>             }
>             if (key.getModulus() == null)
>             {
>                 System.out.println("key.getModulus() is null!");
>                    //***************-------here is the error
>                    //***************-------here is the error
>                    //***************-------here is the error
>                    //***************-------here is the error
>             }
>             bitSize = key.getModulus().bitLength();
>         }
>         catch (Exception e)
>         {
>             e.printStackTrace();
>         }
>
>         if (forEncryption)
>         {
>             return (bitSize + 7) / 8 - 1;
>         }
>         else
>         {
>             return (bitSize + 7) / 8;
>         }
>     }
>
>
> Here is the output:
>
>
> key.getModulus() is null!
> java.lang.NullPointerException
> at
> org.bouncycastle.crypto.engines.RSACoreEngine.getInputBlockSize(RSACoreEngine.java:63)
> at
> org.bouncycastle.crypto.engines.RSABlindedEngine.getInputBlockSize(RSABlindedEngine.java:60)
> at
> org.bouncycastle.crypto.encodings.PKCS1Encoding.encodeBlock(PKCS1Encoding.java:137)
> at
> org.bouncycastle.crypto.encodings.PKCS1Encoding.processBlock(PKCS1Encoding.java:123)
> at
> org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(JDKDigestSignature.java:138)
> at java.security.Signature.sign(Signature.java:527)
> at
> org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(CMSSignedDataGenerator.java:267)
> at
> org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:464)
> at
> org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:398)
> at
> org.bouncycastle.cms.CMSSignedDataGenerator.generate(CMSSignedDataGenerator.java:548)
> at org.linagora.mpe.applet.sign.BCSigner.signerBC(BCSigner.java:209)
> .......................
>
>
>
> Best regards.
>
>
> >
> > What's going into the signers being added to the CMSSignedDataGenerator?
> >
> > Regards,
> >
> > David
> >
> > On Fri, 2007-06-22 at 09:56 +0200, Andrei Munteanu wrote:
> >> Hello.
> >>
> >> I am working to make a java applet work on Linux. I am not sure if the
> >> applet
> >> ever worked on any system....
> >>
> >> I have this error i am fighting with since Thursday. Notice the "Caused
> >> by:
> >> java.security.SignatureException: java.lang.NullPointerException" at the
> >> end.
> >>
> >> Do you know what could be null?
> >>
> >>
> >> Here is the code:
> >>
> >> CMSSignedData signedData = null;
> >> try {
> >> signedData = signGen.generate(content, true,
> >> BouncyCastleProvider.PROVIDER_NAME);
> >> return signedData.getEncoded();
> >> } catch (NoSuchAlgorithmException e) {
> >> LOGGER.fatal("Unable to find selected algorithm  (" + e + ")", e);
> >> } catch (NoSuchProviderException e) {
> >> LOGGER.fatal("Unable to find cryptographic provider (" + e + ")", e);
> >> } catch (CMSException e) {
> >> LOGGER.fatal("Unknown CMS exception2 (" + e + ")", e);
> >> } catch (IOException e) {
> >> LOGGER.fatal("Unable to read file (" + e + ")", e);
> >> }
> >>
> >>
> >> The problem is basically the call:
> >>
> >> signGen.generate(content, true, BouncyCastleProvider.PROVIDER_NAME);
> >>
> >>
> >> The only variables are content and signGen. content seems to be not
> >> empty, and
> >> signGen seems to be well constructed as well. I haven't yet tested the
> >> certificate used to construct signGen, but at least i tested it is not
> >> null.
> >>
> >> However, if i call it this way:
> >>
> >> signGen.generate(content, true, null);
> >>
> >> ....there is no error at all!!!!!!!! Do you have any idea what causes
> >> this "unknown error"?
> >>
> >> Please ask me if you need more information...
> >>
> >>
> >> 107  [AWT-EventQueue-2] FATAL org.linagora.mpe.applet.sign.BCSigner  -
> >> Unknown
> >> CMS exception2 (org.bouncycastle.cms.CMSException: error creating
> >> signature.)
> >> org.bouncycastle.cms.CMSException: error creating signature.
> >> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> >> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> >> at org.bouncycastle.cms.CMSSignedDataGenerator.generate(Unknown Source)
> >> at org.linagora.mpe.applet.sign.BCSigner.signerBC(Unknown Source)
> >> at org.linagora.mpe.applet.sign.Signer.signe(Unknown Source)
> >> at org.linagora.mpe.applet.sign.Action.signer(Unknown Source)
> >> at org.linagora.mpe.applet.PrincipalPanel.actionPerformed(Unknown
> >> Source)
> >> at
> >> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
> >> at
> >> javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
> >> at
> >> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
> >> at
> >> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> >> at
> >> javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
> >> at java.awt.Component.processMouseEvent(Component.java:5501)
> >> at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
> >> at java.awt.Component.processEvent(Component.java:5266)
> >> at java.awt.Container.processEvent(Container.java:1966)
> >> at java.awt.Component.dispatchEventImpl(Component.java:3968)
> >> at java.awt.Container.dispatchEventImpl(Container.java:2024)
> >> at java.awt.Component.dispatchEvent(Component.java:3803)
> >> at
> >> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
> >> at
> >> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> >> at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
> >> at java.awt.Container.dispatchEventImpl(Container.java:2010)
> >> at java.awt.Component.dispatchEvent(Component.java:3803)
> >> at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> >> at
> >> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
> >> at
> >> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
> >> at
> >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> >> at
> >> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> >> at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> >> Caused by: java.security.SignatureException:
> >> java.lang.NullPointerException
> >> at org.bouncycastle.jce.provider.JDKDigestSignature.engineSign(Unknown
> >> Source)
> >> at java.security.Signature.sign(Signature.java:527)
> >> at
> >> org.bouncycastle.cms.CMSSignedDataGenerator$SignerInf.toSignerInfo(Unknown
> >> Source)
> >> ... 30 more
> >>
> >>
> >> --
> >> moa3333
> >>
> >>
> >>
> >
> >
> >
>
>
>


Loading...