Decode responses with Asn1.BER not Asn1.DER

According to RFC 4511 section 5.1:

The protocol elements of LDAP SHALL be encoded for exchange using the
Basic Encoding Rules [BER] of [ASN.1] with the following restrictions
[...]

The library does not have much choice except accepting everything the
server throws at it, therefore it makes sense using the more lax BER
encoding to parse server responses.

Using DER is still ok for the encoding part since DER is still a subset
of BER, and anything accepting BER will accept DER too.
This commit is contained in:
Andrea Bedini 2017-07-04 09:32:07 +08:00
parent b92564e783
commit 824b44ac22
No known key found for this signature in database
GPG Key ID: 44C8FFD37369BE6A

View File

@ -193,7 +193,7 @@ input inq conn = wrap . flip fix [] $ \loop chunks -> do
0 -> throwIO (IO.mkIOError IO.eofErrorType "Ldap.Client.input" Nothing Nothing)
_ -> do
let chunks' = chunk : chunks
case Asn1.decodeASN1 Asn1.DER (ByteString.Lazy.fromChunks (reverse chunks')) of
case Asn1.decodeASN1 Asn1.BER (ByteString.Lazy.fromChunks (reverse chunks')) of
Left Asn1.ParsingPartial
-> loop chunks'
Left e -> throwIO e