最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Send client certificate using XHR - Stack Overflow

programmeradmin4浏览0评论

I'm trying to open an ssl service with java script. In order to do so, I need to send my certificate with xmlhttp object. Can I do it with java script? I could not find how to do it anywhere.

my code looks like this:

xmlhttp.open("post","https://[some ip]:[some secured port]",false);
xmlhttp.send();

However it's not working. On the other hand, when using: "https://[some ip]:[some secured port]" - directly from my browser - It is telling me to choose a certificate and it's working well.

How can I make it work straight from the java script? What should be the solution to my situation?

I'm trying to open an ssl service with java script. In order to do so, I need to send my certificate with xmlhttp object. Can I do it with java script? I could not find how to do it anywhere.

my code looks like this:

xmlhttp.open("post","https://[some ip]:[some secured port]",false);
xmlhttp.send();

However it's not working. On the other hand, when using: "https://[some ip]:[some secured port]" - directly from my browser - It is telling me to choose a certificate and it's working well.

How can I make it work straight from the java script? What should be the solution to my situation?

Share Improve this question edited Mar 11, 2012 at 11:52 matthewk 1,8411 gold badge17 silver badges31 bronze badges asked Mar 11, 2012 at 10:51 user967710user967710 2,0073 gold badges36 silver badges62 bronze badges 1
  • you might wanna read this extensive talk about a similar issue: stackoverflow./q/9542772/575527 – Joseph Commented Mar 11, 2012 at 11:06
Add a ment  | 

2 Answers 2

Reset to default 4

I don't think that's possible.

Besides that, the same origin policy would most likely cause problems for you.

There's one solution you might consider. If you detect that the certificate is absent, you may try to create an iframe with 0 height and width and border: none (basically an invisible iframe), point it to the needed URL and then the browser displays the certificate selection window.

I tested that in Firefox and Edge, both seems to work with that workaround.

发布评论

评论列表(0)

  1. 暂无评论