PEMDocument(pemString:)
does not support Windows line endings
#66
Labels
kind/bug
Feature doesn't work as expected.
size/S
Small task. (A couple of hours of work.)
status/needs-design
Needs further discussion and a concrete proposal.
When initializing a
PEMDocument
(or in my case really a swift-certificatesCertificate
) via apemString:
which comes from a Windows-world service, an error is thrown that it "could not find PEM start marker". The same string piped toopenssl x509
is recognized successfully.I believe the problem is that
swift-asn1/Sources/SwiftASN1/Basic ASN1 Types/PEMDocument.swift
Lines 232 to 239 in 60b2af8
"-----\n"
and thus does not match on what in my case is"-----\r\n"
. (There may be more "\n"-dependent logic beyond that point but this is the source of the initial failure.)The workaround I'm using is to pass in
myPemString.replacingOccurences(of: "\r\n", with: "\n")
but it would be nice if these libraries could handle line breaks more generically. I'm not sure if this is the most relevant standard but RFC 1421 says:which I suppose could be argued that the PEM document conventions could to be local to the receiver but in this case my PEM document is using the "local conventions" of the sender :-)
The text was updated successfully, but these errors were encountered: