简体   繁体   English

使用SPServices和jQuery时将浏览器证书发送到https SharePoint Web服务

[英]Sending the Browser Certificate to an https SharePoint Web Service when using SPServices and jQuery

I am writing some JavaScript to communicate with a SharePoint Web Service that resides behind a firewall and requires a certificate. 我正在编写一些JavaScript,以与位于防火墙后面且需要证书的SharePoint Web Service通信。

I have the right certs installed in my browser. 我的浏览器中安装了正确的证书。 When I browse over to the WSDL I load the page just fine. 当我浏览到WSDL时,我可以正常加载页面。

But when I execute a simple SPServices command (GetListCollection) from a web page using javascript/jQuery, I get an unauthorized error. 但是,当我使用javascript / jQuery从网页执行一个简单的SPServices命令(GetListCollection)时,会出现未授权的错误。

I removed the certs from my browser and tried to load the WSDL and got the exact same error. 我从浏览器中删除了证书,并尝试加载WSDL,并得到了完全相同的错误。 Reinstalling the certs fixes the WSDL view, but my JavaScript still errors out. 重新安装证书可以修复WSDL视图,但是我的JavaScript仍然出错。

I am using this code: 我正在使用此代码:

$().SPService({
  webURL:  [the url],
  operation: "GetListCollection",
  async: false,
  completefunc: function( xData, Status ) {
    console.log( 'Status: ' + Status );
    if ( !!xData ) {
      $( xData.responseXML ).find("Lists > List").each(function() {
        var $node = $(this);
        console.log( $node.attr( "Title" ) );
      });
    }
    else {
       alert('Null result.');
    }
  }
});

Sorry if there are typos in the code; 抱歉,代码中有错别字; this is not cut and paste because my dev box is not connected to the internet. 由于我的开发箱未连接到互联网,因此无法剪切和粘贴。

I think I need to embed a certificate that is installed in the browser (of whoever is running the code on my page) into the web service request, but I have no clue how or where to look for the answer. 我认为我需要将安装在浏览器中的证书(无论谁在我的页面上运行代码的人)嵌入到Web服务请求中,但是我不知道如何或在何处寻找答案。 Any tips would be greatly appreciated. 任何提示将非常感谢。

Turns out you are not allowed to talk to any other servers via https using javascript other than the server you loaded the original page from. 事实证明,除了从其加载原始页面的服务器之外,不允许您使用JavaScript通过https与任何其他服务器进行对话。 It is part of the ajax/javascript security spec. 它是ajax / javascript安全规范的一部分。 So this solution will not work at all. 因此,该解决方案根本无法使用。 I'll have to look into a server-side proxied request solution. 我将不得不研究服务器端代理请求解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM