如何解决使用 XHR 请求加载 SSL 证书
我正在尝试通过 Java 脚本 XHR Web API 调用连接一些第三方 API,我与第三方 API 成功连接,但问题是我无法与 https 协议建立连接,所以我需要在尝试连接时加载 SSL 证书,任何人都可以指导我,如果有的话。
源代码:
// 1. Create a new XMLHttpRequest object
let xhr = new XMLHttpRequest();
// 2. Configure it: GET-request for the URL /article/.../load
xhr.open('POST',url);
// 3.Set headers
xhr.setRequestHeader("Content-type","application/json");
// 4. Send the request over the network
xhr.send();
// 5. This will be called after the response is received
xhr.onload = function() {
if (xhr.status != 201) { // analyze HTTP status of the response
alert(`Error ${xhr.status}: ${xhr.statusText}`); // e.g. 404: Not Found
} else { // show the result
alert("Success");
};
xhr.onprogress = function(event) {
if (event.lengthComputable) {
//alert(`Received ${event.loaded} of ${event.total} bytes`);
} else {
//alert(`Received ${event.loaded} bytes`); // no Content-Length
}
目标:
var xhr = new XMLHttpRequest();
xhr.onload = function() {
console.log(this.responseXML.title);
}
xhr.open("GET","ROOT.cer");
xhr.responseType = "document";
xhr.send();
因此,根据目标,我需要建立加载 SSL ROOT 证书的连接,如果有任何解决方案,请告诉我。
谢谢,
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。