<?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>193508</bug_id>
          
          <creation_ts>2019-01-16 13:51:13 -0800</creation_ts>
          <short_desc>sendBeacon to previously-unvisited https domain always fails</short_desc>
          <delta_ts>2019-04-25 06:56:25 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>WebKit Local Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.chromium.org/p/chromium/issues/detail?id=878562</see_also>
          <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>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Ali Juma">ajuma</reporter>
          <assigned_to name="Alex Christensen">achristensen</assigned_to>
          <cc>achristensen</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>ggaren</cc>
    
    <cc>stefan</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1495218</commentid>
    <comment_count>0</comment_count>
    <who name="Ali Juma">ajuma</who>
    <bug_when>2019-01-16 13:51:13 -0800</bug_when>
    <thetext>PingLoad::didReceiveChallenge always returns AuthenticationChallengeDisposition::Cancel, so calls to sendBeacon(url) where url is an https URL for a domain that we&apos;re establishing an https connection for the first time will always fail.

Once we establish an https connection some other way (e.g. by sending an xhr to the same domain), PingLoads no longer receive a challenge, so beacons are successfully sent.

This bug doesn&apos;t affect Safari, because in [WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler], _session-&gt;networkProcess().canHandleHTTPSServerTrustEvaluation() is false, so we always call the completion handler with NSURLSessionAuthChallengeRejectProtectionSpace.

However, for other WebKit embedders (e.g., MiniBrowser, and all non-Safari browsers on iOS), canHandleHTTPSServerTrustEvaluation() is true, so we do call into PingLoad::didReceiveChallenge and cancel the network task.

A possible fix would making PingLoad::didReceiveChallenge return RejectProtectionSpaceAndContinue, which would have the effect of allowing connections to sites with valid certificates and rejecting otherwise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1495221</commentid>
    <comment_count>1</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-01-16 14:03:46 -0800</bug_when>
    <thetext>We could fix this by using PerformDefaultHandling if it&apos;s for ProtectionSpaceAuthenticationSchemeServerTrustEvaluationRequested</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1495284</commentid>
    <comment_count>2</comment_count>
      <attachid>359325</attachid>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-01-16 15:48:21 -0800</bug_when>
    <thetext>Created attachment 359325
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1495298</commentid>
    <comment_count>3</comment_count>
      <attachid>359325</attachid>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2019-01-16 15:59:45 -0800</bug_when>
    <thetext>Comment on attachment 359325
Patch

Can we add a regression test for this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1495299</commentid>
    <comment_count>4</comment_count>
      <attachid>359325</attachid>
    <who name="youenn fablet">youennf</who>
    <bug_when>2019-01-16 16:00:53 -0800</bug_when>
    <thetext>Comment on attachment 359325
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=359325&amp;action=review

&gt; Source/WebKit/NetworkProcess/PingLoad.cpp:123
&gt;      auto weakThis = makeWeakPtr(*this);

This line could go after the if check.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1495315</commentid>
    <comment_count>5</comment_count>
    <who name="Alex Christensen">achristensen</who>
    <bug_when>2019-01-16 16:20:50 -0800</bug_when>
    <thetext>(In reply to Geoffrey Garen from comment #3)
&gt; Comment on attachment 359325 [details]
&gt; Patch
&gt; 
&gt; Can we add a regression test for this?
We currently do not have the infrastructure to do so.  I would like to develop such infrastructure.

http://trac.webkit.org/r240094</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>359325</attachid>
            <date>2019-01-16 15:48:21 -0800</date>
            <delta_ts>2019-01-16 15:59:45 -0800</delta_ts>
            <desc>Patch</desc>
            <filename>bug-193508-20190116154820.patch</filename>
            <type>text/plain</type>
            <size>1708</size>
            <attacher name="Alex Christensen">achristensen</attacher>
            
              <data encoding="base64">SW5kZXg6IFNvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCj09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIFNvdXJjZS9XZWJL
aXQvQ2hhbmdlTG9nCShyZXZpc2lvbiAyNDAwODcpCisrKyBTb3VyY2UvV2ViS2l0L0NoYW5nZUxv
Zwkod29ya2luZyBjb3B5KQpAQCAtMSwzICsxLDE0IEBACisyMDE5LTAxLTE2ICBBbGV4IENocmlz
dGVuc2VuICA8YWNocmlzdGVuc2VuQHdlYmtpdC5vcmc+CisKKyAgICAgICAgc2VuZEJlYWNvbiB0
byBwcmV2aW91c2x5LXVudmlzaXRlZCBodHRwcyBkb21haW4gYWx3YXlzIGZhaWxzCisgICAgICAg
IGh0dHBzOi8vYnVncy53ZWJraXQub3JnL3Nob3dfYnVnLmNnaT9pZD0xOTM1MDgKKworICAgICAg
ICBSZXZpZXdlZCBieSBOT0JPRFkgKE9PUFMhKS4KKworICAgICAgICAqIE5ldHdvcmtQcm9jZXNz
L1Bpbm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Qog
ewogICAgIFJFTEVBU0VfTE9HX0lGX0FMTE9XRUQoImRpZFJlY2VpdmVDaGFsbGVuZ2UiKTsKICAg
ICBhdXRvIHdlYWtUaGlzID0gbWFrZVdlYWtQdHIoKnRoaXMpOworICAgIGlmIChjaGFsbGVuZ2Uu
cHJvdGVjdGlvblNwYWNlKCkuYXV0aGVudGljYXRpb25TY2hlbWUoKSA9PSBQcm90ZWN0aW9uU3Bh
Y2VBdXRoZW50aWNhdGlvblNjaGVtZVNlcnZlclRydXN0RXZhbHVhdGlvblJlcXVlc3RlZCkgewor
ICAgICAgICBjb21wbGV0aW9uSGFuZGxlcihBdXRoZW50aWNhdGlvbkNoYWxsZW5nZURpc3Bvc2l0
aW9uOjpQZXJmb3JtRGVmYXVsdEhhbmRsaW5nLCB7IH0pOworICAgICAgICByZXR1cm47CisgICAg
fQogICAgIGNvbXBsZXRpb25IYW5kbGVyKEF1dGhlbnRpY2F0aW9uQ2hhbGxlbmdlRGlzcG9zaXRp
b246OkNhbmNlbCwgeyB9KTsKICAgICBpZiAoIXdlYWtUaGlzKQogICAgICAgICByZXR1cm47Cg==
</data>
<flag name="review"
          id="376110"
          type_id="1"
          status="+"
          setter="ggaren"
    />
          </attachment>
      

    </bug>

</bugzilla>