异常的SslStream.AuthenticateAsClient(该消息格式错误) [英] Exception on SslStream.AuthenticateAsClient (The message was badly formatted)

查看:883
本文介绍了异常的SslStream.AuthenticateAsClient(该消息格式错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有奇怪的问题怎么回事。我想通过TCP / SSL连接到苹果服务器。我使用的推送通知提供的苹果客户端证书。我在我的服务器(WIN2K3)在本地受信任的根证书和本地个人证书文件夹中安装的证书。

I have got wierd problem going on. I am trying to connect to Apple server via TCP/SSL. I am using a Client certificate provided by Apple for push notifications. I installed the certificate on my server (Win2k3) in both Local Trusted Root certificates and Local Personal Certificates folder.

现在我有一个类库,随着该连接处理,当我把这个类库从它的工作原理精绝的服务器上运行一个控制台应用程序,但是当我调用类库从一个asp.net页面或ASMX网页服务,我得到下面的异常。

Now I have a class library that deals with that connection, when i call this class library from a console application running from the server it works absolutely fine, but when i call that class library from an asp.net page or asmx web service I get the following exception.

一个调用SSPI失败,请参见内部异常。收到的消息是意外或格式。

A call to SSPI failed, see inner exception. The message received was unexpected or badly formatted.

这是我的code:

X509Certificate cert = new X509Certificate(certificateLocation, certificatePassword);                       
X509CertificateCollection certCollection = new X509CertificateCollection(new X509Certificate[1] { cert });
// OPEN the new SSL Stream
SslStream ssl = new SslStream(client.GetStream(), false, new RemoteCertificateValidationCallback(ValidateServerCertificate), null);                       
ssl.AuthenticateAsClient(ipAddress, certCollection, SslProtocols.Default, false);

ssl.AuthenticateAsClient 是错误被抛出。

这是我发疯。如果控制台应用程序可以正常连接,必须有一些问题,asp.net网络层安全是认证失败的...不知道,也许需要添加一些东西,或在web.config某种安全策略。也只是想指出,我可以都与控制台和网站的正常连接在我的本地开发机器。

This is driving me nuts. If the console application can connect fine, there must be some problem with asp.net network layer security that is failing the authentication... not sure, perhaps need to add something or some sort of security policy in the web.config. Also just to point out that i can connect fine on my local development machine both with console and website.

任何人有什么想法?

推荐答案

您已经安装在系统上的证书?如果您运行的是Windows应该是在管理控制台本地计算机/个人或受信任的文件夹(运行 - > MMC)。

Have you installed the certificate on your system? If you are running windows it should be in Local Computer/Personal or Trusted Folders under Management Console (Run -> mmc).

这篇关于异常的SslStream.AuthenticateAsClient(该消息格式错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆