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

Detached signature content-type oid does not match actual content-type #24

Closed
dawud-tan opened this issue Dec 30, 2017 · 0 comments
Closed

Comments

@dawud-tan
Copy link

dawud-tan commented Dec 30, 2017

// Detach removes content from the signed data struct to make it a detached signature.
// This must be called right before Finish()
func (sd *SignedData) Detach() {
	sd.sd.ContentInfo = contentInfo{ContentType: oidSignedData}
}

Is pkcs7.go's Detach function, do cause mismatch Content-Type according to RFC 3852 Section 11.1?

following is my code line hello.go line 108, it will send a response to my android app that use bouncycastle lib, the lib throws following error new CMSException("content-type attribute value does not match eContentType");, it check this if (!signedContentType.equals(contentType))

the Content-Type of the following openssl smime v3.1 detached signature command line tool:
openssl cms -sign -md sha1 -noattr -signer public.crt -inkey public.key -in PO.edifact -out signedPO.edifact, is 1.2.840.113549.1.7.1, while your detached function is 1.2.840.113549.1.7.2

following is the sample of the above hello.go's http response

------=_Part_zBgVxyST
Content-Type: multipart/report; report-type=disposition-notification; 
	boundary="----=_Part_NXmQfJcR"

------=_Part_NXmQfJcR
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

The AS2 message has been received.
------=_Part_NXmQfJcR
Content-Type: message/disposition-notification
Content-Transfer-Encoding: 7bit

Reporting-UA: php AS2 Server
Original-Recipient: rfc822; mendelsontestAS2
Final-Recipient: rfc822; mendelsontestAS2
Original-Message-ID: <github-dawud-tan-RetrofitSmime-30122017110750+0700--380012012302437852@mycompanyAS2_mendelsontestAS2>
Disposition: automatic-action/MDN-sent-automatically; processed
Received-Content-MIC: PAitTZmshnYdaYVQ5aYyf/cEJiE=, sha1

------=_Part_NXmQfJcR--

------=_Part_zBgVxyST
Content-Type: application/pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"

MIIExwYJKoZIhvcNAQcCo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JAYJKoZIhvcNAQkBFhdyb3Nl
dHRhbmV0QG1lbmRlbHNvbi5kZTELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxp
bjEPMA0GA1UEBxMGQmVybGluMSIwIAYDVQQKExltZW5kZWxzb24tZS1jb21tZXJj
ZSBHbWJIMSIwIAYDVQQLExltZW5kZWxzb24tZS1jb21tZXJjZSBHbWJIMQ0wCwYD
VQQDEwRtZW5kAgRDjv3zMAcGBSsOAwIaoGEwGAYJKoZIhvcNAQkDMQsGCSqGSIb3
DQEHATAgBgkqhkiG9w0BCQUxExcRMTcxMjMwMTEwNzUyKzA3MDAwIwYJKoZIhvcN
AQkEMRYEFEJE7uZ+32tvKMiJuDT4uaOVYO+tMAsGCSqGSIb3DQEBAQSBgFJA0aXE
LIwP4aslsRk3OjWD6Rrw1oSK4YcxlcVEAal/29TVWAwEKVdlkPOxOhUUipYN7VD1
9aIhZQMXVEd6ar+E8CcTEWnZztPbTlM/rlciqzB88/ZkTgpRqxUeCsnloPhOe3Vo
1rNzqHeHpmsCcyTNq1TvaQGkchjJ3N22UTZB

------=_Part_zBgVxyST--

msiebeling pushed a commit to sggms/pkcs7 that referenced this issue Nov 25, 2019
The content type should be oidData.

Fixes fullsailor#24
jessepeterson pushed a commit to jessepeterson/pkcs7 that referenced this issue Apr 30, 2024
fix(ber): prevent race due to unnecessary var
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