Рукопожатие терпит неудачу с Безопасными веб-сокетами с libWebSocket
Я занимаюсь разработкой приложения для Android, которое использует libwebsockets для создания защищенных веб-сокетов. Хотя незащищенные веб-сокеты работают нормально, но у меня возникают проблемы с защищенными. Я недавно обновил версию OpenSSL до 1.0.2n. При просмотре журналов Chrome кажется, что первоначальное рукопожатие не удается.
04-03 17:31:41.000 E/chromium( 9526): [ERROR:ssl_client_socket_impl.cc(1129)] handshake failed; returned -1, SSL error code 1, net_error -107
04-03 17:31:41.117 I/chromium( 9526): [INFO:CONSOLE(126)] "WebSocket connection to 'wss://localhost:43448/' failed: Error in connection establishment: net::ERR_SSL_PROTOCOL_ERROR"
Затем я включил ведение журнала библиотеки libwebsockets. Получил следующие логи:
04-03 17:31:36.630 D/testApp( 9526): _realloc: size 424: create vhost
Line 219: 04-03 17:31:36.630 D/testApp( 9526): _realloc: size 84: vhost-specific plugin table
Line 220: 04-03 17:31:36.630 D/testApp( 9526): _realloc: size 8: same vh list
Line 221: 04-03 17:31:36.630 I/testApp( 9526): Creating Vhost 'localhost' port 0, 2 protocols, IPv6 off
Line 222: 04-03 17:31:36.630 D/testApp( 9526): _realloc: size 488: listen wsi
Line 223: 04-03 17:31:36.630 D/testApp( 9526): insert_wsi_socket_into_fds: 0xcfd6de00: tsi=0, sock=87, pos-in-fds=1
Line 224: 04-03 17:31:36.630 I/testApp( 9526): Listening on port 43448
Line 594: 04-03 17:31:36.881 I/testApp( 9526): lws_protocol_init
Line 652: 04-03 17:31:38.349 D/testApp( 9526): _realloc: size 424: create vhost
Line 653: 04-03 17:31:38.349 D/testApp( 9526): _realloc: size 84: vhost-specific plugin table
Line 654: 04-03 17:31:38.349 D/testApp( 9526): _realloc: size 8: same vh list
Line 655: 04-03 17:31:38.349 I/testApp( 9526): Creating Vhost 'localhost' port 0, 2 protocols, IPv6 off
Line 656: 04-03 17:31:38.349 D/testApp( 9526): _realloc: size 488: listen wsi
Line 657: 04-03 17:31:38.349 D/testApp( 9526): insert_wsi_socket_into_fds: 0xd04f4000: tsi=0, sock=108, pos-in-fds=2
Line 658: 04-03 17:31:38.350 I/testApp( 9526): Listening on port 45831
Line 659: 04-03 17:31:38.350 I/testApp( 9526): lws_protocol_init
Line 863: 04-03 17:31:40.995 D/testApp( 9526): accepted new conn port 43036 on fd=188
Line 864: 04-03 17:31:40.995 D/testApp( 9526): _realloc: size 488: new server wsi
Line 865: 04-03 17:31:40.995 D/testApp( 9526): new wsi 0xd04f4200 joining vhost localhost, tsi 0
Line 866: 04-03 17:31:40.995 D/testApp( 9526): lws_adopt_descriptor_vhost: new wsi 0xd04f4200, sockfd 188
Line 867: 04-03 17:31:40.995 D/testApp( 9526): lws_set_timeout: 0xd04f4200: 20 secs
Line 868: 04-03 17:31:40.995 D/testApp( 9526): insert_wsi_socket_into_fds: 0xd04f4200: tsi=0, sock=188, pos-in-fds=3
Line 869: 04-03 17:31:40.995 I/testApp( 9526): lws_header_table_attach: wsi 0xd04f4200: ah 0x0 (tsi 0, count = 0) in
Line 870: 04-03 17:31:40.995 D/testApp( 9526): _realloc: size 2936: ah struct
Line 871: 04-03 17:31:40.995 D/testApp( 9526): _realloc: size 4096: ah data
Line 872: 04-03 17:31:40.995 I/testApp( 9526): _lws_create_ah: created ah 0xc01fdc00 (size 4096): pool length 1
Line 873: 04-03 17:31:40.995 I/testApp( 9526): lws_header_table_attach: did attach wsi 0xd04f4200: ah 0xc01fdc00: count 1 (on exit)
Line 874: 04-03 17:31:40.995 D/testApp( 9526): lws_set_timeout: 0xd04f4200: 10 secs
Line 875: 04-03 17:31:40.995 D/testApp( 9526): Attached ah immediately
Line 878: 04-03 17:31:40.995 D/testApp( 9526): issuing 175 bytes to parser
Line 879: 04-03 17:31:40.995 D/testApp( 9526):
Line 881: 04-03 17:31:40.996 D/testApp( 9526): 0000: 16 03 01 00 AA 01 00 00 A6 03 03 6B 70 53 7C B0 ...........kpS|.
Line 882: 04-03 17:31:40.996 D/testApp( 9526): 0010: 45 9A 76 80 F2 23 73 61 AA 42 E7 1B C4 D7 CB 8E E.v..#sa.B......
Line 883: 04-03 17:31:40.996 D/testApp( 9526): 0020: DD E1 BE B1 31 24 0F 09 EC 4B DD 00 00 1C 6A 6A ....1$...K....jj
Line 884: 04-03 17:31:40.996 D/testApp( 9526): 0030: C0 2B C0 2F C0 2C C0 30 CC A9 CC A8 C0 13 C0 14 .+./.,.0........
Line 885: 04-03 17:31:40.996 D/testApp( 9526): 0040: 00 9C 00 9D 00 2F 00 35 00 0A 01 00 00 61 5A 5A ...../.5.....aZZ
Line 886: 04-03 17:31:40.996 D/testApp( 9526): 0050: 00 00 FF 01 00 01 00 00 00 00 0E 00 0C 00 00 09 ................
Line 887: 04-03 17:31:40.996 D/testApp( 9526): 0060: 6C 6F 63 61 6C 68 6F 73 74 00 17 00 00 00 23 00 localhost.....#.
Line 888: 04-03 17:31:40.996 D/testApp( 9526): 0070: 00 00 0D 00 14 00 12 04 03 08 04 04 01 05 03 08 ................
Line 889: 04-03 17:31:40.996 D/testApp( 9526): 0080: 05 05 01 08 06 06 01 02 01 00 05 00 05 01 00 00 ................
Line 890: 04-03 17:31:40.996 D/testApp( 9526): 0090: 00 00 00 12 00 00 00 0B 00 02 01 00 00 0A 00 0A ................
Line 891: 04-03 17:31:40.996 D/testApp( 9526): 00A0: 00 08 7A 7A 00 1D 00 17 00 18 7A 7A 00 01 00 ..zz......zz...
Line 892: 04-03 17:31:40.996 D/testApp( 9526):
Line 894: 04-03 17:31:40.996 D/testApp( 9526):
Line 895: 04-03 17:31:40.997 D/testApp( 9526): 0000: 16 03 01 00 AA 01 00 00 A6 03 03 6B 70 53 7C B0 ...........kpS|.
Line 896: 04-03 17:31:40.997 D/testApp( 9526): 0010: 45 9A 76 80 F2 23 73 61 AA 42 E7 1B C4 D7 CB 8E E.v..#sa.B......
Line 897: 04-03 17:31:40.997 D/testApp( 9526): 0020: DD E1 BE B1 31 24 0F 09 EC 4B DD 00 00 1C 6A 6A ....1$...K....jj
Line 898: 04-03 17:31:40.997 D/testApp( 9526): 0030: C0 2B C0 2F C0 2C C0 30 CC A9 CC A8 C0 13 C0 14 .+./.,.0........
Line 899: 04-03 17:31:40.997 D/testApp( 9526): 0040: 00 9C 00 9D 00 2F 00 35 00 0A 01 00 00 61 5A 5A ...../.5.....aZZ
Line 900: 04-03 17:31:40.997 D/testApp( 9526): 0050: 00 00 FF 01 00 01 00 00 00 00 0E 00 0C 00 00 09 ................
Line 901: 04-03 17:31:40.997 D/testApp( 9526): 0060: 6C 6F 63 61 6C 68 6F 73 74 00 17 00 00 00 23 00 localhost.....#.
Line 902: 04-03 17:31:40.997 D/testApp( 9526): 0070: 00 00 0D 00 14 00 12 04 03 08 04 04 01 05 03 08 ................
Line 903: 04-03 17:31:40.997 D/testApp( 9526): 0080: 05 05 01 08 06 06 01 02 01 00 05 00 05 01 00 00 ................
Line 904: 04-03 17:31:40.997 D/testApp( 9526): 0090: 00 00 00 12 00 00 00 0B 00 02 01 00 00 0A 00 0A ................
Line 905: 04-03 17:31:40.997 D/testApp( 9526): 00A0: 00 08 7A 7A 00 1D 00 17 00 18 7A 7A 00 01 00 ..zz......zz...
Line 906: 04-03 17:31:40.997 D/testApp( 9526):
Line 908: 04-03 17:31:40.998 D/testApp( 9526): WSI_TOKEN_NAME_PART '' 0x16 (mode=0) wsi->u.hdr.lextable_pos=0
Line 912: 04-03 17:31:40.999 I/testApp( 9526): Unknown method - dropping
Line 913: 04-03 17:31:40.999 I/testApp( 9526): forbidding on uri sanitation
Line 915: 04-03 17:31:41.000 I/testApp( 9526): lws_return_http_status: return
Line 916: 04-03 17:31:41.000 I/testApp( 9526): lws_parse failed
Line 917: 04-03 17:31:41.000 I/testApp( 9526): lws_header_table_detach: wsi 0xd04f4200: ah 0xc01fdc00 (tsi=0, count = 1)
Line 918: 04-03 17:31:41.001 I/testApp( 9526): lws_header_table_detach: nobody usable waiting
Line 919: 04-03 17:31:41.001 I/testApp( 9526): _lws_destroy_ah: freed ah 0xc01fdc00 : pool length 0
Line 920: 04-03 17:31:41.001 I/testApp( 9526): lws_header_table_detach: wsi 0xd04f4200: ah 0xc01fdc00 (tsi=0, count = 0)
Line 921: 04-03 17:31:41.001 D/testApp( 9526): lws_close_free_wsi: 0xd04f4200
Line 922: 04-03 17:31:41.001 I/testApp( 9526): lws_close_free_wsi: shutdown conn: 0xd04f4200 (sock 188, state 0)
Line 923: 04-03 17:31:41.001 D/testApp( 9526): lws_close_free_wsi: real just_kill_connection: 0xd04f4200 (sockfd 188)
Line 924: 04-03 17:31:41.001 I/testApp( 9526): lws_same_vh_protocol_remove: removing same prot wsi 0xd04f4200
Line 925: 04-03 17:31:41.001 D/testApp( 9526): remove_wsi_socket_from_fds: wsi=0xd04f4200, sock=188, fds pos=3, end guy pos=4, endfd=0
Line 926: 04-03 17:31:41.001 D/testApp( 9526): not calling back closed mode=0 state=0
Line 927: 04-03 17:31:41.001 I/testApp( 9526): ah det due to close
Line 928: 04-03 17:31:41.001 D/testApp( 9526): lws_free_wsi: 0xd04f4200, remaining wsi 2
Line 930: 04-03 17:31:41.001 D/testApp( 9526): accepted new conn port 34338 on fd=177
Line 931: 04-03 17:31:41.001 D/testApp( 9526): _realloc: size 488: new server wsi
Line 932: 04-03 17:31:41.002 D/testApp( 9526): new wsi 0xd04f4200 joining vhost localhost, tsi 0
Line 933: 04-03 17:31:41.002 D/testApp( 9526): lws_adopt_descriptor_vhost: new wsi 0xd04f4200, sockfd 177
Line 934: 04-03 17:31:41.002 D/testApp( 9526): lws_set_timeout: 0xd04f4200: 20 secs
Line 935: 04-03 17:31:41.002 D/testApp( 9526): insert_wsi_socket_into_fds: 0xd04f4200: tsi=0, sock=177, pos-in-fds=3
Line 936: 04-03 17:31:41.002 I/testApp( 9526): lws_header_table_attach: wsi 0xd04f4200: ah 0x0 (tsi 0, count = 0) in
Line 937: 04-03 17:31:41.002 D/testApp( 9526): _realloc: size 2936: ah struct
Line 938: 04-03 17:31:41.002 D/testApp( 9526): _realloc: size 4096: ah data
Line 939: 04-03 17:31:41.002 I/testApp( 9526): _lws_create_ah: created ah 0xc01fdc00 (size 4096): pool length 1
Line 940: 04-03 17:31:41.002 I/testApp( 9526): lws_header_table_attach: did attach wsi 0xd04f4200: ah 0xc01fdc00: count 1 (on exit)
Line 941: 04-03 17:31:41.002 D/testApp( 9526): lws_set_timeout: 0xd04f4200: 10 secs
Line 942: 04-03 17:31:41.002 D/testApp( 9526): Attached ah immediately
Line 945: 04-03 17:31:41.002 D/testApp( 9526): issuing 175 bytes to parser
Но я не могу судить о проблеме из журналов выше. Похоже, что ниже строка дает проблемы, но я не уверен в этом.
Line 912: 04-03 17:31:40.999 I/testApp( 9526): Unknown method - dropping
У кого-нибудь есть идеи по этому поводу.