Update 'smime/smime.go'

This commit is contained in:
Marek Goc 2022-10-22 09:10:57 +00:00
parent 3f58f9a4b2
commit d9a5f65e09

View File

@ -1,6 +1,6 @@
//Package smime implants parts of the S/MIME 4.0 specification rfc5751-bis-12.
// Package smime implants parts of the S/MIME 4.0 specification rfc5751-bis-12.
//
//See https://www.ietf.org/id/draft-ietf-lamps-rfc5751-bis-12.txt
// See https://www.ietf.org/id/draft-ietf-lamps-rfc5751-bis-12.txt
package smime
import (
@ -251,19 +251,19 @@ func (smime *SMIME) Sign(msg []byte) (signedMsg []byte, err error) {
return
}
signedPart.SetHeaderField([]byte("Content-Type"), contentType[0])
contentTransferEncoding := mail.GetHeaderField([]byte("Content-Transfer-Encoding"))
if len(contentType) == 1 {
signedPart.SetHeaderField([]byte("Content-Transfer-Encoding"), contentTransferEncoding[0])
}
contentDisposition := mail.GetHeaderField([]byte("Content-Disposition"))
if len(contentType) == 1 {
signedPart.SetHeaderField([]byte("Content-Disposition"), contentDisposition[0])
}
// contentTransferEncoding := mail.GetHeaderField([]byte("Content-Transfer-Encoding"))
// if len(contentType) == 1 {
// signedPart.SetHeaderField([]byte("Content-Transfer-Encoding"), contentTransferEncoding[0])
// }
// contentDisposition := mail.GetHeaderField([]byte("Content-Disposition"))
// if len(contentType) == 1 {
// signedPart.SetHeaderField([]byte("Content-Disposition"), contentDisposition[0])
// }
// Sign
lines := mime.ParseLines(signedPart.Full())
signatureDER, err := smime.CMS.Sign(lines.Bytes(mime.CRLF), true)
// fmt.Println(signatureDER)
// Encode signature
signature := mime.MIME{}