<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>41419</bug_id>
          
          <creation_ts>2010-06-30 10:07:52 -0700</creation_ts>
          <short_desc>We should log the reason when a secure wss WebSocket connection could not be established</short_desc>
          <delta_ts>2026-01-12 09:03:26 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Web Inspector</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>40945</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Martyn Loughran">mail</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>ap</cc>
    
    <cc>bfulgham</cc>
    
    <cc>fishd</cc>
    
    <cc>graouts</cc>
    
    <cc>inspector-bugzilla-changes</cc>
    
    <cc>joenotcharles</cc>
    
    <cc>localcaliguyofoc</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>wilander</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>244828</commentid>
    <comment_count>0</comment_count>
    <who name="Martyn Loughran">mail</who>
    <bug_when>2010-06-30 10:07:52 -0700</bug_when>
    <thetext>I have not been able to connect to a secure wss:// websocket servers using either Safari 5 or the WebKit nightly.

I have tried the following server implementations: em-websocket (http://github.com/igrigorik/em-websocket) and pywebsocket (http://code.google.com/p/pywebsocket/). For both servers I used a self signed certificate, which I also added as a trusted certificate to my keychain (which made no difference). Both of these server implementations work with Chrome (tested with version 6.0.447.0 dev).

It appears that there is an error establishing an SSL connection. The stacktrace from pywebsocket (instructions to replicate below) looks like this.

    [2010-06-30 17:24:10,655] [ERROR] root: Exception in processing request from: (&apos;127.0.0.1&apos;, 59399)
    Traceback (most recent call last):
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;, line 558, in process_request_thread
        self.finish_request(request, client_address)
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;, line 320, in finish_request
        self.RequestHandlerClass(request, client_address, self)
      File &quot;standalone.py&quot;, line 237, in __init__
        self, *args, **keywords)
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/SocketServer.py&quot;, line 615, in __init__
        self.handle()
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py&quot;, line 329, in handle
        self.handle_one_request()
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/BaseHTTPServer.py&quot;, line 312, in handle_one_request
        self.raw_requestline = self.rfile.readline()
      File &quot;/Library/Python/2.6/site-packages/mod_pywebsocket/memorizingfile.py&quot;, line 71, in readline
        line = self._file.readline()
      File &quot;/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/socket.py&quot;, line 395, in readline
        data = recv(1)
    Error: [(&apos;SSL routines&apos;, &apos;SSL23_READ&apos;, &apos;ssl handshake failure&apos;)]

I also tried using stunnel in front of a patched em-websocket server (operating in non ssl mode, but returning the correct wss handshake). This worked in Chrome, but for the WebKit case the connection was terminated in stunnel with the following debug log:

    2010.06.30 17:20:47 LOG7[31326:140735074479136]: wss accepted FD=11 from 127.0.0.1:59205
    2010.06.30 17:20:47 LOG7[31326:4297367552]: wss started
    2010.06.30 17:20:47 LOG7[31326:4297367552]: FD 11 in non-blocking mode
    2010.06.30 17:20:47 LOG7[31326:4297367552]: Waiting for a libwrap process
    2010.06.30 17:20:47 LOG7[31326:4297367552]: Acquired libwrap process #0
    2010.06.30 17:20:47 LOG7[31326:4297367552]: Releasing libwrap process #0
    2010.06.30 17:20:47 LOG7[31326:4297367552]: Released libwrap process #0
    2010.06.30 17:20:47 LOG7[31326:4297367552]: wss permitted by libwrap from 127.0.0.1:59205
    2010.06.30 17:20:47 LOG5[31326:4297367552]: wss accepted connection from 127.0.0.1:59205
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): before/accept initialization
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): SSLv3 read client hello A
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): SSLv3 write server hello A
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): SSLv3 write certificate A
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): SSLv3 write server done A
    2010.06.30 17:20:47 LOG7[31326:4297367552]: SSL state (accept): SSLv3 flush data
    2010.06.30 17:20:47 LOG3[31326:4297367552]: SSL_accept: Peer suddenly disconnected
    2010.06.30 17:20:47 LOG5[31326:4297367552]: Connection reset: 0 bytes sent to SSL, 0 bytes sent to socket
    2010.06.30 17:20:47 LOG7[31326:4297367552]: wss finished (0 left)

Nothing is logged in Safari or to Console.app, so I&apos;m slightly at a loss how to debug further.

Replicating with pywebsocket:

* Download from http://code.google.com/p/pywebsocket/
* Install (see README)
* Run standalone server
** cd `src/mod_pywebsocket`
** `sudo python standalone.py -t -p 443 -k keyfile -c certfile --allow-draft75`
* Connect from WebKit</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>245381</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-07-01 09:21:04 -0700</bug_when>
    <thetext>What happens if you try to connect to the same host via HTTP (i.e., by entering an http:// address in address bar)? Is there an SSL certificate error displayed?

WebSocket spec says:

   4.   If /secure/ is true, perform a TLS handshake over the
        connection.  If this fails (e.g. the server&apos;s certificate could
        not be verified), then fail the WebSocket connection and abort
        these steps.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>245382</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-07-01 09:22:06 -0700</bug_when>
    <thetext>&gt; entering an http:// address

I meant https://, sorry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>246666</commentid>
    <comment_count>3</comment_count>
    <who name="Martyn Loughran">mail</who>
    <bug_when>2010-07-05 08:49:57 -0700</bug_when>
    <thetext>Alexey,

You&apos;re absolutely correct. The self signed certificate was not trusted by Safari and after changing the setting to always trust this certificate the WebSocket connection worked. So thanks!

I wonder though whether it would be possible to make this more user friendly? Bringing up the same certificate warning message that Safari uses for https would seem to be ideal, but if that&apos;s not possible at least logging the failure reason somewhere would be really useful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>246743</commentid>
    <comment_count>4</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2010-07-05 12:27:13 -0700</bug_when>
    <thetext>Logging is absolutely what we should do. I&apos;m not convinced that a warning sheet is a good idea - providing an easy way to bypass security equals to having no security at all, and we can avoid that for WebSocket, that would be good.

We might eventually have to show the warning sheet due to pressure from other browsers (I&apos;m told Chrome does that).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1026583</commentid>
    <comment_count>5</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2014-08-03 19:28:55 -0700</bug_when>
    <thetext>&lt;rdar://problem/17898486&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>