Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/fix verfiy signature #161

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions openpdf/src/main/java/com/lowagie/text/pdf/PdfPKCS7.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@


import com.lowagie.text.error_messages.MessageLocalization;
import org.bouncycastle.asn1.BERTaggedObject;

/**
* This class does all the processing related to signing and verifying a PKCS#7
Expand Down Expand Up @@ -421,8 +422,11 @@ public PdfPKCS7(byte[] contentsKey, String provider) {
throw new IllegalArgumentException(
MessageLocalization
.getComposedMessage("not.a.valid.pkcs.7.object.not.signed.data"));
ASN1Sequence content = (ASN1Sequence) ((DERTaggedObject) signedData
.getObjectAt(1)).getObject();
ASN1Sequence content = (ASN1Sequence) (
(signedData.getObjectAt(1) instanceof BERTaggedObject) ?
(BERTaggedObject) signedData.getObjectAt(1) :
(DERTaggedObject) signedData.getObjectAt(1))
.getObject();
// the positions that we care are:
// 0 - version
// 1 - digestAlgorithms
Expand Down Expand Up @@ -460,7 +464,8 @@ public PdfPKCS7(byte[] contentsKey, String provider) {

// the signerInfos
int next = 3;
while (content.getObjectAt(next) instanceof DERTaggedObject)
while (content.getObjectAt(next) instanceof DERTaggedObject ||
content.getObjectAt(next) instanceof BERTaggedObject)
++next;
ASN1Set signerInfos = (ASN1Set) content.getObjectAt(next);
if (signerInfos.size() != 1)
Expand Down