From 824b44ac22eb68d734500e5378e2be50f315fefb Mon Sep 17 00:00:00 2001 From: Andrea Bedini Date: Tue, 4 Jul 2017 09:32:07 +0800 Subject: [PATCH] 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. --- src/Ldap/Client.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ldap/Client.hs b/src/Ldap/Client.hs index bf8ad71..50493de 100644 --- a/src/Ldap/Client.hs +++ b/src/Ldap/Client.hs @@ -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