fetch()在使用SSL客户端身份验证的Firefox中失败 [英] fetch() fails in Firefox with SSL client authentication

查看:192
本文介绍了fetch()在使用SSL客户端身份验证的Firefox中失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用SSL客户端认证的Web服务器。该服务器上的网页使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆