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

verifying signature-test: no content type #4

Open
nathany opened this issue Feb 3, 2016 · 3 comments
Open

verifying signature-test: no content type #4

nathany opened this issue Feb 3, 2016 · 3 comments

Comments

@nathany
Copy link

nathany commented Feb 3, 2016

Though the code is working for Safari push and Passbook passes, if I asn1.Unmarshal the result in a test, I get an error:

asn1: syntax error: sequence truncated

var container container
_, err = asn1.Unmarshal(data, &container)

if err != nil {
    t.Fatal(err)
}

CFSSL's ParsePKCS7 gives the same error.

If I import "github.com/cloudflare/cfssl/crypto/pkcs7"

_, err := pkcs7.ParsePKCS7(data)
if err != nil {
    t.Fatal(err)
}

I'm not sure if I'm doing this right, but calling openssl to verify the output gives this error:

> /usr/local/opt/openssl/bin/openssl smime -verify -in signature-test
Error reading S/MIME message
140735153643600:error:0D0D40D1:asn1 encoding routines:SMIME_read_ASN1:no content type:asn_mime.c:440:
@nathany
Copy link
Author

nathany commented Feb 3, 2016

This isn't a surprise, but using signpass executable has no problems at all. It comes with the PassKit support materials in the Wallet Developer Guide.

❯ signpass -v Event.pkpass 
Signature valid.
Certificates: (
    0: Pass Type ID: pass.com.github.RobotsAndPencils.buford
    1: Apple Worldwide Developer Relations Certification Authority
)
Trust chain is valid.

*** SUCCEEDED ***

Still, it would be nice to write more tests for this library, and unmarshalling the asn1 seems like the first step. By the way, I am using Go 1.6 rc1 right now, but the same error occurs on Go 1.5 and Go 1.4.

@nathany
Copy link
Author

nathany commented Feb 3, 2016

For a different approach, I tried unmarshalling (in Go) a signature from one of Apple's sample passes. That didn't work either, but with a different error:

asn1: syntax error: indefinite length found (not DER)

Apple is using (CMS) based on RFC 3852 which uses BER. There is a newer RFC 5652 as well.

Go's asn1 package only supports the DER subset. golang/go#12267

So while it's possible to encode something Apple will accept, it's not possible to build a full CMS implementation without also reimplementing asn1 to support BER. Not that we necessarily need full CMS. This issue is just about trying to find a way to test this code.

@nathany
Copy link
Author

nathany commented Feb 5, 2016

I am able to unmarshal when using https://github.com/st3fan/gocrypto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant