botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Skype Bot Premature TCP FIN Packets After TLS Negotiation

Open theonewolf opened this issue 10 years ago • 13 comments

About 10% of the webhook requests coming into my web server, presumably to POST, triggered by Skype messaging actually work and POST properly.

90% of all webhook requests end early abruptly with a TCP FIN packet sent from a Microsoft server.

Has anyone encountered this issue before? Is this because our server is using the OpenSSL library with restrictive options? I tried using weaker ciphers and TLS versions, but that didn't help at all.

These unexpected FIN packets result in the following NGINX debug log:

2016/06/09 19:25:32 [debug] 11293#0: *9 http wait request handler
2016/06/09 19:25:32 [debug] 11293#0: *9 malloc: 00007F71AF8201C0:1024
2016/06/09 19:25:32 [debug] 11293#0: *9 SSL_read: 0
2016/06/09 19:25:32 [debug] 11293#0: *9 SSL_get_error: 5
2016/06/09 19:25:32 [debug] 11293#0: *9 peer shutdown SSL cleanly
2016/06/09 19:25:32 [info] 11293#0: *9 client closed connection while waiting for request, client: 40.77.163.66, server: 0.0.0.0:443
2016/06/09 19:25:32 [debug] 11293#0: *9 close http connection: 13
2016/06/09 19:25:32 [debug] 11293#0: *9 SSL_shutdown: 1

and the more rare good connection looks like this:

2016/06/09 19:25:32 [debug] 11293#0: *10 http wait request handler
2016/06/09 19:25:32 [debug] 11293#0: *10 malloc: 00007F71AF8201C0:1024
2016/06/09 19:25:32 [debug] 11293#0: *10 SSL_read: -1
2016/06/09 19:25:32 [debug] 11293#0: *10 SSL_get_error: 2
2016/06/09 19:25:32 [debug] 11293#0: *10 free: 00007F71AF8201C0
2016/06/09 19:25:33 [debug] 11293#0: *10 post event 00007F71AF88DD80
2016/06/09 19:25:33 [debug] 11293#0: *10 delete posted event 00007F71AF88DD80
2016/06/09 19:25:33 [debug] 11293#0: *10 http wait request handler
2016/06/09 19:25:33 [debug] 11293#0: *10 malloc: 00007F71AF8201C0:1024
2016/06/09 19:25:33 [debug] 11293#0: *10 SSL_read: 156
2016/06/09 19:25:33 [debug] 11293#0: *10 SSL_read: -1
2016/06/09 19:25:33 [debug] 11293#0: *10 SSL_get_error: 2
2016/06/09 19:25:33 [debug] 11293#0: *10 reusable connection: 0

and this is a Wireshark screenshot of the unexpected FIN packet:

wireshark-tcp-fin-skype

Finally, this is what a good connection looks like (again, happens only 10% of the time):

wireshark-tcp-good

theonewolf avatar Jun 09 '16 20:06 theonewolf

I am experiencing the same issue, however I am not using nginx to forward data, I have my bot as an embedded jetty service listening for connections on the server itself, and I still experience the same sort of packet disconnects. I am using a Let's Encrypt SSL cert

linuxdaemon avatar Jun 10 '16 19:06 linuxdaemon

As reported in the community Skype developer forum, this was directly related to using Let's Encrypt certificates.

The Skype Bot platform does not support Let's Encrypt, although this is not publicly documented anywhere.

I switched my certificates to an alternate CA, and things started working perfectly (no more missed POSTs).

Can anyone tell us a timeline for including such a globally recognized CA?

theonewolf avatar Jun 10 '16 21:06 theonewolf

I'm guessing your certs from Let's Encrypt are valid, but they don't chain to a cert trusted by our servers. To get onto the list of CAs installed on Windows, a certificate authority must first be a Microsoft trusted CA, and I don't see Let's Encrypt on the latter list, let alone the former.

Complete list of Microsoft trusted CAs: http://social.technet.microsoft.com/wiki/contents/articles/31634.microsoft-trusted-root-certificate-program-participants-v-2016-april.aspx Application requirements to become a trusted CA: https://technet.microsoft.com/en-us/library/cc751157.aspx

dandriscoll avatar Jun 21 '16 18:06 dandriscoll

Precisely, they probably don't chain to a trusted CA on some of your servers. However...27%-30% of my callbacks work with your servers and a Let's Encrypt Certificate. I documented this in the Skype community forums for developers. There is some misconfiguration on your end:

I just sent 300 Skype messages to our test bot, which resulted in 300 connections to our NGINX server:

218 failed early (within 1 second, FIN packet) 82 succeeded to POST correctly, we sent an empty 201 Created response

About 27% of POSTs actually properly get to our web server.

Post: https://community.skype.com/t5/Skype-Bot-Developers/Unexpected-FIN-Packets/gpm-p/4411251

On my Windows 8.1 Enterprise system I visited https://helloworld.letsencrypt.org/ with Internet Explorer and the entire certificate chain validates fine (I have not installed anything custom with PKI on my system):

image

The noted root: DST Root CA X3 is in Microsoft Trusted CA list on all major OS versions AFAICT.

Now, I admit, Let's Encrypt is cross-signing with the DST Root CA X3, but it should still work (it works with most other MS software). It is valid.

I believe their main root ISRG Root X1 is currently undergoing the process you linked (becoming a trusted CA from MS perspective ready to ship), although I am not sure.

Some more information is here: https://community.letsencrypt.org/t/which-browsers-and-operating-systems-support-lets-encrypt/4394

If you want savvy modern devs working with this API, I suggest fixing support for Let's Encrypt :-)

theonewolf avatar Jun 23 '16 21:06 theonewolf

If anybody happens to come across this page looking for mysterious TLS issues, I've been informed that Bot Framework doesn't support TLS1.2, only 1.0. I note 1.2 in your Wireshark screenshots. Is your alternate CA only using 1.0?

Microsoft, is that true or is a stranger on StackOverflow just messing with me?

konnichimade avatar Jun 24 '16 23:06 konnichimade

TLS 1.2 is a server configuration setting, not a certificate setting.

Our web server is configured to only speak TLS 1.2.

With a different certificate this works perfectly.

The issue was completely solved by us when we switched to a certificate from StartSSL.

All callbacks are going through correctly, with TLS 1.2.

theonewolf avatar Jun 25 '16 18:06 theonewolf

Well hmph. HyperDev is using a certificate from DigiCert, the same CA that the Bot Framework's own website uses.

image

image

But it's being rejected.

konnichimade avatar Jun 29 '16 20:06 konnichimade

No requests coming through? Or just some sporadically?

theonewolf avatar Jun 29 '16 20:06 theonewolf

I'm sending requests from the "Test connection to your bot" box on the Bot Framework site, and it's coming back with the following error:

An error occurred while sending the request. The request was aborted: Could not create SSL/TLS secure channel. [HPrOQmnygPG]

I am logging requests at my endpoint and it's not showing anything coming through. Unfortunately, I can't do anything so thorough as you have done, because I don't own the server.

I have tried sending a request to a completely different API, and it responds as expected.

konnichimade avatar Jun 30 '16 17:06 konnichimade

A Microsoft representative (presumably) is still claiming that they cannot create outbound connections using TLS 1.2.

konnichimade avatar Jul 01 '16 19:07 konnichimade

Our server config (NGINX) looks like this:

    ssl_protocols TLSv1.2;
    ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA";

    ssl_prefer_server_ciphers on;

We definitely never allow anything other than TLS 1.2, and are getting a 100% hit rate with the API right now.

theonewolf avatar Jul 02 '16 19:07 theonewolf

Hello, has anyone been experiencing this issue lately?

danmarshall avatar Aug 12 '16 19:08 danmarshall

Per this comment on the above-linked SO question, my issue was fixed on July 8.

konnichimade avatar Sep 26 '16 21:09 konnichimade