Open nitin-singh opened 8 years ago
Exact same issue, Any luck?
Hi, I'm tryng to create a passbook and I had exact issue but I could to resolve it.
You should code:
PassSigner signer = PassSignerImpl.builder()
.keystore(new FileInputStream("pkpass/certificates/CertificatesD.p12", **"PASS_CERTIFICATE"**)
.alias(**"NAME_ALIAS"**)
.intermediateCertificate(new FileInputStream("pkpass/certificates/AppleWWDRCA.cer"))
.build();
PassSerializer.writePkPassArchive(pass, signer, new FileOutputStream("passes/DemoCard.pkpass"));
Let me know how you go!
I had the same issue and found a solution. Instead of passing the certificate and an alias you need to create your own keystore and load the certificate and then pass that keystore to the PassSigner.
First create the keystore
KeyStore keystore = KeyStore.getInstance("PKCS12");
Load your certificate/keypair
keystore.load(inputStreamForP12, "passwordForP12".toCharArray());
Create the PassSigner
PassSigner signer = PassSignerImpl.builder().keystore(keystore, "passwordForP123").intermediateCertificate(inputStreamForWWDRCA).build();
Hi @martinreichart / @ryantenney ,
The solution given above by @martinreichart worked for me, while executing it on Windows machine with Oracle JDK 1.6.045. But when I deployed the same code on our linux server (WAS8) IBM JDK 1.6, its giving me below error.
.PassbookServiceImpl - Create Sign-In Request for com.dataobjects.v2.reservation.passbook.SignPassRequest@cde4fa73 .PassbookServiceImpl - Validate Signin Request .PassbookServiceImpl - Valid Signin Request .PassbookBOImpl - Inside PassbookBOImpl class - createSignPass method started .PassbookBOImpl - Inside PassbookBOImpl method - getPassSigner method started .PassbookBOImpl - Inside PassbookBOImpl method - getPassSignerForRitzCarlton method started .PassbookBOImpl - Initializing the Pass Signer for : ritz.carlton.passbook.rewards.pass.file .PassbookBOImpl - ######################## Aliases are :[jean mountford, pass type id: pass.com.ritzcarlton.dev.reservationpass] .PassbookBOImpl - Problem generating signer for passbook com.ryantenney.passkit4j.sign.PassSigningException: Provided KeyStore contains multiple aliases, please specify an alias at com.ryantenney.passkit4j.sign.PassSigningUtil.firstAlias(PassSigningUtil.java:136) ~[passkit4j-2.0.4.jar:na] at com.ryantenney.passkit4j.sign.PassSigningUtil.getCertificate(PassSigningUtil.java:100) ~[passkit4j-2.0.4.jar:na] at com.ryantenney.passkit4j.sign.PassSignerImpl$Builder.build(PassSignerImpl.java:111) ~[passkit4j-2.0.4.jar:na] at com.reservation.v2.business.impl.PassbookBOImpl.initializeSigner(PassbookBOImpl.java:303) [classes/:na] at com.reservation.v2.business.impl.PassbookBOImpl.getRitzCarltonRewardsPassSigner(PassbookBOImpl.java:513) [classes/:na] at com.reservation.v2.business.impl.PassbookBOImpl.getPassSignerForRitzCarlton(PassbookBOImpl.java:217) [classes/:na] at com.reservation.v2.business.impl.PassbookBOImpl.getPassSigner(PassbookBOImpl.java:195) [classes/:na] at com.reservation.v2.business.impl.PassbookBOImpl.createSignPass(PassbookBOImpl.java:115) [classes/:na] at com.reservation.v2.services.impl.PassbookServiceImpl.createSignPass(PassbookServiceImpl.java:57) [classes/:na]
Here is the code snippet: ` try { // Create Keystore KeyStore keystore = KeyStore.getInstance("PKCS12"); // Load Cert Pass (.p12 file) certPassIS = new FileInputStream(ResourceUtils.getFile(passFileName)); // Load the Apple cert appleCertIS = new FileInputStream(ResourceUtils.getFile(appleCertPass)); / Create the PassSigner / keystore.load(certPassIS, certPass.toCharArray()); passSigner = PassSignerImpl.builder().keystore(keystore, certPass).intermediateCertificate(appleCertIS).build(); } catch (Exception e) { e.printStackTrace();
} ` Could you please help.
We have found the solution for this. Here is the fix. We need to pass the provider for the underlying keystore, i.e. SunJSSE or IBMJCE
`try { // Create Keystore KeyStore keystore = KeyStore.getInstance("PKCS12","IBMJCE"); // Load Cert Pass (.p12 file) certPassIS = new FileInputStream(ResourceUtils.getFile(passFileName)); // Load the Apple cert appleCertIS = new FileInputStream(ResourceUtils.getFile(appleCertPass)); / Create the PassSigner / keystore.load(certPassIS, certPass.toCharArray()); passSigner = PassSignerImpl.builder().keystore(keystore, certPass).intermediateCertificate(appleCertIS).build(); } catch (Exception e) { e.printStackTrace();
}`
@ychoudhary/ @martinreichart / @ryantenney I was trying to use the solution which worked for you when i run the class i get following error , I guess it because i imported my keystore from import java.security.KeyStore; Is there any alternative solution for my problem. StoreCardExample.txt
java.lang.SecurityException: class "org.bouncycastle.asn1.DEREncodable"'s signer information does not match signer information of other classes in the same package
@vamshisomanchi in your case the problem seems to be that you have multiple versions of BouncyCastle on your classpath.
Just had this issue, and I had it every year since 2017. In my case the solution is to remove whitespaces from the alias name, my alias was "my name lastname" and changing to "mnl" or "my_name_lastname" fixed this issue.
openssl pkcs12 -in cert.p12
and then search for friendlyName use it the PassSignerImpl.bulder()
.alias("aliasFound")
I am using this code in my grails application. I tried various scenarios like:
P.S I am using ubuntu 14.04.