问题
I want to port actionmailer_x509 to Rails 3. In order to do that I try to create Mail object from big string with signed email.
You can see such creation on this line: https://github.com/petRUShka/actionmailer_x509/blob/master/lib/actionmailer_x509.rb#L129
Original string (smime0): https://gist.github.com/1d2c84cc2e255be010a6
Resulted Mail object dumped to file(newm): https://gist.github.com/4682fe88e8dcfeca60b2
For example, you can see the difference between line 26 of smime0 and line 40 of newm. In smime0 \r\n
is setted after each 64 chars, and in newm \r\n
is setted after each 60 chars.
Such behaviour brokes signature. Is it possible to change this behaviour? I tried to find out how to turn off it, but was failed.
May be there is some other workaround for this point.
P.S. Mail gem: https://github.com/mikel/mail, thread with discussion about x509 and actionmailer: How do I send signed emails from ActionMailer in Rails 3?
回答1:
The carriage returns shouldn't be a problem, because the parser will know that it's base64 encoded (and will discard \r\n
).
I think the error comes from the Content-id. I see that in your mail samples, newm adds a Content-ID field, and it changes the signed message (try to remove the Content-ID line and verify the message).
Possible workarounds:
- Fix the Mail gem to prevent it from adding a Content-ID
- Add a Content-ID before signing, because Mail will keep it if it's present
来源:https://stackoverflow.com/questions/6663409/ruby-mail-gem-add-r-n-after-60-chars-in-mail