allow configuration of which base64-encoding scheme to use for outbound messages #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
up to this point we have always used
Base64.strict_encode64
, which is RFC-4648 rules.a partner using MuleSoft AS2 was unable to successfully receive messages encoded this way. they are able to receive messages encoded using RFC-2045 rules, which is
Base64.encode64
in ruby.differences between the 2 schemes
There are differences in the exact alphabet of characters used, but for our purposes the most important difference is this:
RFC-2045 specifies a maximum line length of 78 characters.
\n
is inserted between 78-character segments to form the final output.RFC-4648 does not have any requirement to break lines, so does not insert any
\n
characters.Effects on MIC calculation
MIC values must be calculated on canonicalized message bodies.
https://datatracker.ietf.org/doc/html/rfc4130#section-7.3.1
This means we must replace the
\n
in any RFC-2045 encoded text with\r\n
in order to calculate a correct MIC value. This canonicalization (via regex) was already being performed in a few other places in the codebase, so this has been extracted into a newAs2.canonicalize_line_endings
method for clarity.