Using jQuery's ajax() function with an SSL cli

2019-02-21 14:30发布

I want to make a XHR call to a REST service using the ajax() function of jQuery. Basically, this works fine, but the REST service is only accessible by https, and requires the client to authenticate using a client certificate.

How do I send a client certificate using jQuery's ajax() function?

2条回答
我只想做你的唯一
2楼-- · 2019-02-21 15:17

It's possible to make ssl ajax calls if the request source and target are in the same domain and using https: Securing AJAX & SSL. But you can't make an ssl authentication within your ajax call.

查看更多
Fickle 薄情
3楼-- · 2019-02-21 15:26

Client-certificate authentication is (a) only performed upon request by the server and (b) done transparently by the browser, as far as the HTTP and JavaScript layers are concerned.

When the server requests a client certificate (which may entail a re-negotiation following an HTTP request), the browser should offer a pop-up to select a certificate (which is browser-dependent and not under any JavaScript or HTML control) or select one automatically depending on its settings.

As such, it's not up to jQuery's ajax() function to do anything about the client certificate.

Off the top of my head, I'm not sure whether the browser will trigger the client-certificate selection pop-up if it only occurs at first during that AJAX call (this is likely to be browser dependent). However, if the client-certificate selection has already been made (or if the choice is automatic), the browser will use it for authentication, as it would for any other normal request.

查看更多
登录 后发表回答