我已经开发了Web API服务,该服务可以向另一个需要个人证书的Web API发出请求。
当我在本地PC上开发此服务时,我像这样使用HttpClient:
_handler = new HttpClientHandler()
{ ClientCertificateOptions = ClientCertificateOption.Automatic };
_client = new HttpClient(_handler);
我的个人证书是从我的PC上获取的。
然后,我想将项目发布到Windows Server 2012 R2上的IIS 8。
首先,我已经在服务器上安装了所有证书,并在IIS中设置了应用程序池,IIS由服务用户启动,但是我的API应用程序使用了我帐户的池(证书已绑定到该池)。但是,当我尝试发出请求时,会出现如下异常:
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>An error occurred while sending the request.</ExceptionMessage>
<ExceptionType>System.Net.Http.HttpRequestException</ExceptionType>
<StackTrace/>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
</ExceptionMessage>
<ExceptionType>System.Net.WebException</ExceptionType>
<StackTrace>
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context) at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
</StackTrace>
<InnerException>
<Message>An error has occurred.</Message>
<ExceptionMessage>
The remote certificate is invalid according to the validation procedure.
</ExceptionMessage>
<ExceptionType>
System.Security.Authentication.AuthenticationException
</ExceptionType>
<StackTrace>
at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult) at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
</StackTrace>
</InnerException>
</InnerException>
</InnerException>
我认为我的问题是IIS无法使用我已安装在Windows Server上的证书。
我该如何解决?
答案 0 :(得分:0)
首先必须信任证书,而且有时读取证书也存在问题。检查IIS_IUSERS(应用程序池用户)是否具有读取访问权限:
更好的解决方案可能是创建真实证书(非自签名) 尤其是如果这是一个公共api。
那些不再花费金钱的服务,例如let's encrypt之类的服务和win-acme之类的IIS工具(以前的lets-encrypt-win-simple),它将为您生成IIS中所有绑定的证书。也有很多其他选择。
答案 1 :(得分:-2)
在调用HttpClient之前使用它。请记住,此代码仅适用于开发机器。请勿在生产中使用
Spark data frame support following types of joins between two dataframes.
Please find the list of joins and joining string with respect to join types along with scala syntax.
We can use following joining values used for specify the join type in Scala- Spark code.
***Mathod:*** Leftdataframe.join(Rightdataframe, join_conditions, joinStringName)
Join Name : Join String name in scala -Spark code
1. inner : 'inner'
2. cross: 'cross'
3. outer: 'outer'
4. full: 'full'
5. full outer: 'fullouter'
6. left : 'left'
7. left outer : 'leftouter'
8. right : 'right'
9. right outer : 'rightouter'
10. left semi: 'leftsemi'
11. left anti: 'leftanti'
example: 1. Left Semi join:
Leftdataframe.join(Rightdataframe, join_conditions, "leftsemi");
2. inner Join Example:
Leftdataframe.join(Rightdataframe, join_conditions, "inner");
Its tested and working well.