fetch()在使用SSL客户端身份验证的Firefox中失败 [英] fetch() fails in Firefox with SSL client authentication
问题描述
fetch()
API进行同源 GET
请求。 在Chrome中,客户端证书按照预期以SSL握手方式发送,导致200ok响应。在Firefox中,证书不会被发送,导致403禁止的响应。
在Firefox中,如果使用 ()
到 XMLHttpRequest
,它的工作原理。如果我直接从Firefox的URL栏加载相同的URL,它的工作原理。这个问题似乎局限于Firefox上的 fetch()
。
有没有人见过这个?有什么办法可以使Firefox中的SSL客户端身份验证使 fetch()
顺利运行,或者是否需要切换到使用 XMLHttpRequest
到处都是?谢谢。
我刚刚解决了我自己的问题。这是失败的:
fetch(someUrl)
解决了这个问题:
$ f $ fetch(someUrl,{credentials:'包括'})
显然,Chrome(v54)和Firefox(v45) / p>
I have a web server which uses SSL client authentication. A web page on that server makes a same-origin GET
request using the fetch()
API.
In Chrome, the client cert is sent in the SSL handshake, as expected, resulting in a 200 "ok" response. In Firefox, the cert isn't sent, resulting in a 403 "forbidden" response.
In Firefox, if I switch it from using fetch()
to XMLHttpRequest
, it works. If I load the same URL directly from Firefox's URL bar, it works. The problem seems limited to fetch()
on Firefox.
Has anyone seen this before? Is there any way to make fetch()
play well with SSL client auth in Firefox, or do I need to switch to using XMLHttpRequest
everywhere? Thanks.
I just solved my own problem. This is what was failing:
fetch(someUrl)
This fixes the issue:
fetch(someUrl, { credentials: 'include' })
Apparently there's different behavior here between Chrome (v54) and Firefox (v45).
这篇关于fetch()在使用SSL客户端身份验证的Firefox中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!