ryantenney / passkit4j

Java library for generating Apple Passbook (.pkpass) files

Home Page:http://www.ryantenney.com/passkit4j/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incompatibility with BouncyCastle 1.5x?

ybroze opened this issue · comments

We've had some issues using passkit4j with the newest BouncyCastle library. The exception and stacktrace are pretty perplexing as well!

Core exception:

2016-06-14 20:49:02,479 ERROR (web.errors.GrailsExceptionResolver) VerifyError occurred when processing request: [GET] /our/mobile/app/endpoint/
Bad type on operand stack
Exception Details:
  Location:
    org/bouncycastle/cms/CMSSignedDataGenerator.generate(Ljava/lang/String;Lorg/bouncycastle/cms/CMSProcessable;ZLjava/security/Provider;Z)Lorg/bouncycastle/cms/CMSSignedData; @301: invokevirtual
  Reason:
    Type 'org/bouncycastle/asn1/ASN1ObjectIdentifier' (current frame, stack[2]) is not assignable to 'org/bouncycastle/asn1/DERObjectIdentifier'
  Current Frame:
    bci: @301
    flags: { }
    locals: { 'org/bouncycastle/cms/CMSSignedDataGenerator', 'java/lang/String', 'org/bouncycastle/cms/CMSProcessable', integer, 'java/security/Provider', integer, 'org/bouncycastle/asn1/ASN1EncodableVector', 'org/bouncycastle/asn1/ASN1EncodableVector', integer, 'org/bouncycastle/asn1/ASN1ObjectIdentifier', 'java/util/Iterator', 'org/bouncycastle/cms/CMSSignedDataGenerator$SignerInf' }
    stack: { 'org/bouncycastle/asn1/ASN1EncodableVector', 'org/bouncycastle/cms/CMSSignedDataGenerator$SignerInf', 'org/bouncycastle/asn1/ASN1ObjectIdentifier', 'org/bouncycastle/cms/CMSProcessable', 'java/security/SecureRandom', 'java/security/Provider', integer }
  Bytecode:

  ... <lots of hexdump> ...

Additional stack trace:

...
    at com.ryantenney.passkit4j.sign.PassSignerImpl.createGenerator(PassSignerImpl.java:136)
    at com.ryantenney.passkit4j.sign.PassSignerImpl.<init>(PassSignerImpl.java:128)
    at com.ryantenney.passkit4j.sign.PassSignerImpl$Builder.build(PassSignerImpl.java:122)
    at com.todaytix.cms.PassbookService.createPassForTransaction(PassbookService.groovy:115)
...

The core issue seems to be a change made for BouncyCastle 1.47, wherein DERObjectIdentifier was renamed to ASN1ObjectIdentifier.

@jessestuart has been troubleshooting a bit here at @TodayTix.

Thanks for the heads up. I guess it would make sense to upgrade the library to use the latest BC and this fix this issue. I'll take a look at it a little later and see if the upgrade goes smoothly.

Hi,
The problem is when you have two distinct dependency of bouncycastle.
For example: bcprov-jdk16 (v1.46) and bcprov-jdk15on (v1.54).
I had this two dependencies ones and I deleted the first one.

I could to make a pass with bcprov-jdk15on (v1.54).

Seems this is all fine and dandy!