Ewsexception unexpected HTTP response

0 votes
asked Oct 20 by geoecaldima (120 points)

I have this "Rebex.Net.EwsException exception: unexpected HTTP response" while logging

I've try different authentication method, different SSL Mode. The TLS Handshake looks Ok.

what am I doing wrong?

Thank you

Detailed log:

FileLogWriter(8)[11] Info: Assembly: Rebex.Common 2020 R4 for .NET 4.0-4.8
FileLogWriter(8)[11] Info: Platform: Windows 10.0.14393 64-bit; CLR: 4.0.30319.42000
FileLogWriter(8)[11] Info: Culture: fr; Windows-1252
EWS: Executing Connect method.
EWS: Connecting to https://mail.xXxXxXxX.fr:443 using Ews.
Info: Assembly: Rebex.Ews 2020 R4 for .NET 4.0-4.8
Info: Platform: Windows 10.0.14393 64-bit; CLR: 4.0.30319.42000
Info: Culture: fr; Windows-1252
HTTP: Connecting to 'https://mail.xXxXxXxX.fr:443'...
Info: Assembly: Rebex.Networking 2020 R4 for .NET 4.0-4.8
Info: Platform: Windows 10.0.14393 64-bit; CLR: 4.0.30319.42000
Info: Culture: fr; Windows-1252
Proxy: Resolving 'mail.xXxXxXxX.fr'.
Proxy: Connecting to xx.xx.xx.xx:443 (no proxy).
Proxy: Connection established.
TLS: Using classic TLS core.
TLS: Enabled cipher suites: 0x000F3DF7EBE00640.
TLS: Applicable cipher suites: 0x000F3DF7EBE00640.
TLS: HandshakeMessage:ClientHello was sent.
TLS: HandshakeMessage:ServerHello was received.
TLS: Negotiating TLS 1.2, RSA with ephemeral ECDH, AES with 128-bit key in GCM mode, AEAD.
TLS: The server supports secure renegotiation.
TLS: HandshakeMessage:Certificate was received.
TLS: HandshakeMessage:ServerKeyExchange was received.
TLS: HandshakeMessage:ServerHelloDone was received.
TLS: Verifying server certificate ('CN=mail.xXxXxXxX.fr, O=xxxx., L=PARIS, S=Île-de-France, C=FR').
TLS: Certificate verification result: Accept
TLS: Verifying server key exchange signature.
TLS: Using ephemeral ECDH public key exchange with NIST P-256 curve.
TLS: HandshakeMessage:ClientKeyExchange was sent.
TLS: CipherSpec:ChangeCipherSpec was sent.
TLS: HandshakeMessage:Finished was sent.
TLS: CipherSpec:ChangeCipherSpec was received.
TLS: HandshakeMessage:Finished was received.
TLS: Connection secured using cipher: TLS 1.2, RSA with ephemeral ECDH, AES with 128-bit key in GCM mode, AEAD.
HTTP: Sending request: HEAD /EWS/Services.wsdl
HTTP: PreAuthenticate: False
HTTP: Request Connection: keep-alive.
HTTP: Sending request (124 bytes).
HTTP: Received response: 401 Unauthorized.
HTTP: Received 14 headers.
HTTP: Response Content-Length: 0 bytes.
HTTP: Response Connection not specified; using 'keep-alive'.
HTTP: Response Content-Encoding not specified.
HTTP: Server requires authentication: Basic realm="mail.xXxXxXxX.fr"
HTTP: Server requires authentication: Negotiate
HTTP: Server requires authentication: NTLM
EWS: Server supports OAuth 2.0: True
EWS: Connect succeeded.
EWS: Executing Login method.
EWS: Authenticating to Exchange server as 'mail@server.fr'.
EWS: Executing GetFolderId method.
HTTP: Sending request: POST /EWS/Exchange.asmx
HTTP: PreAuthenticate: False
HTTP: Request Connection: keep-alive.
HTTP: Sending request (270 bytes).
HTTP: Sending 581 bytes of data.
HTTP: Received response: 401 Unauthorized.
HTTP: Received 11 headers.
HTTP: Response Content-Length: 0 bytes.
HTTP: Response Connection not specified; using 'keep-alive'.
HTTP: Response Content-Encoding not specified.
HTTP: Response Transfer-Encoding not specified.
HTTP: Server requires authentication: Basic realm="mail.xXxXxXxX.fr"
HTTP: Server requires authentication: Negotiate
HTTP: Server requires authentication: NTLM
HTTP: Discarding pending response data...
HTTP: Received content (0 bytes).
HTTP: Closing response stream.
HTTP: Attempting 'Negotiate' authentication.
HTTP: Authentication message: Negotiate TlRMTVNTUAABAAAAl4II4
HTTP: Sending request: POST /EWS/Exchange.asmx
HTTP: PreAuthenticate: False
HTTP: Request Connection: keep-alive.
HTTP: Sending request (353 bytes).
HTTP: Sending 581 bytes of data.
HTTP: Received response: 401 Unauthorized.
HTTP: Received 11 headers.
HTTP: Response Content-Length: 0 bytes.
HTTP: Response Connection not specified; using 'keep-alive'.
HTTP: Response Content-Encoding not specified.
HTTP: Response Transfer-Encoding not specified.
HTTP: Server requires authentication: Negotiate TlRMTVNTUAACAAAAE
HTTP: Server requires authentication: Basic realm="mail.xXxXxXxX.fr"
HTTP: Server requires authentication: NTLM
HTTP: Authentication challenge: TlRMTVNTUAACA
HTTP: Discarding pending response data...
HTTP: Received content (0 bytes).
HTTP: Closing response stream.
HTTP: Authentication message: Negotiate TlRMTVNTUAADAAAAG
HTTP: Sending request: POST /EWS/Exchange.asmx
HTTP: PreAuthenticate: False
HTTP: Request Connection: keep-alive.
HTTP: Sending request (1005 bytes).
HTTP: Sending 581 bytes of data.
HTTP: Received response: 400 Bad Request.
HTTP: Received 12 headers.
HTTP: Response Content-Length: 48 bytes.
HTTP: Response Connection not specified; using 'keep-alive'.
HTTP: Response Content-Encoding not specified.
HTTP: Response Transfer-Encoding not specified.
HTTP: Request failed: 400 Bad Request
EWS: GetFolderId failed: Rebex.Net.EwsException: Unexpected HTTP response. ---> hqclv.vhucl: 400 Bad Request
--- End of inner exception stack trace ---
at hqclv.sfreo.jpyxt[T](String p0, Object p1)
at Rebex.Net.Ews.dahop(EwsFolderId p0, iveiz p1)
at Rebex.Net.Ews.hqclv.refiw.rusqy()
at Rebex.Net.Ews.sofql[T](String p0, Func`1 p1, rllcm p2)
2021-10-20 11:09:39.285 DEBUG Ews(316)[11] HTTP: Closing HTTP session (310).
2021-10-20 11:09:39.285 DEBUG Ews(316)[11] TLS: Closing TLS socket.
2021-10-20 11:09:39.286 DEBUG Ews(316)[11] TLS: Alert:CloseNotify was sent.

Applies to: Rebex HTTPS

1 Answer

0 votes
answered Oct 20 by Pavel Matyska (15,060 points)

Hello,

it seems that you are not connecting to an Exchange server. It would be helpful if you know what the server send when reported 400 Bad Request. If it is not in our original log (this one is stripped off of request and response messages), you can turn on verbose logging and see it in the received packet. I guess there is a html page with some description in the response what went wrong.

commented Oct 20 by geoecaldima (120 points)
Hi Verbose loggin is already in my question ...

The exception is raised on   " EwSClient.Login(InboxLogin, InboxPassword, Rebex.Net.EwsAuthentication.Auto)  "

Thank you
commented Oct 21 by Pavel Matyska (15,060 points)
Hello,
what you provided in your original question is clearly not our log (I don't mind hiding server name). It does not contains all fields and information that our DEBUG log produce, as these are lines from our DEBUG log.

Please create a VERBOSE log and send it to our support@rebex.net mailbox for analysis. You can set the logger after Ews.Connect method which will result in only failing Login method in the log (and you will save time to hide your server name). It should contain our SOAP request to your server and the server response, in the worst case as pure paket data. From that we should be able to tell what is wrong on your system.
...