通过SSL的HttpWebRequest [英] HttpWebRequest over SSL

查看:88
本文介绍了通过SSL的HttpWebRequest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用尽所有其他途径解决了这个问题。任何帮助都将非常感谢

.


我通过HttpWebRequest对象执行简单的POST到SSL URL

https://)。我已经尝试了几个不同的地址,没有

运气。我也试图向

ServicePointManager提供新的ICertificatePolicy。我收到的错误的奇怪之处是

它甚至在发送任何数据之前发生。


注意:此代码运行良好从控制台应用程序中。从Web应用程序执行它的时候,它失败了。我已经尝试了

模仿,没有运气。


------------------ --------

HttpWebRequest WebRequest =

(HttpWebRequest)System.Net.WebRequest.Create(" http s://www.anywherewithsslsup

port.com");

WebRequest.KeepAlive = true;

WebRequest.ContentType =" application / x-www-form-urlencoded" ;

WebRequest.Method =" POST";

WebRequest.AllowAutoRedirect = false;


string Data =" = true& itdoesnot = matter& whatever = willfai l" ;;

WebRequest.ContentLength = Data.Length;


System.IO.Stream RequestStream = WebRequest。 GetRequestStream();

--------------------------


错误发生在上面代码的最后一行,出现以下错误

消息:


System.EntryPointNotFoundException:无法找到名为
EnumerateSecurit DLL security.dll中的yPackagesW。

我很难过。任何人都可以对这个错误有所了解吗?它发生在

我测试过的两台计算机上。两者都是带有.NET 1.1的Win2K。


提前谢谢,


-

Matt Sollars
ma**@hypersite.net

------------ -------

Hypersite网络

2002 N. Salisbury Blvd.

套房C

索尔兹伯里,马里兰州21801

T:410.749.2000

F:410.219.3400
http://www.hypersite.net

I''ve exhausted all other avenues with this problem. Any help would be
greatly appreciated.

I am performing a simple POST via a HttpWebRequest object to an SSL URL
(https://). I have attempted this to several different addresses with no
luck. I''ve tried to supply a new ICertificatePolicy to the
ServicePointManager as well. The oddity of the error that I''m receiving is
it''s happening before any data is even sent.

Note: This code works wonderfully from within a console application. The
moment it is executed from a web application, it fails. I''ve tried
impersonation as well with no luck.

--------------------------
HttpWebRequest WebRequest =
(HttpWebRequest)System.Net.WebRequest.Create("http s://www.anywherewithsslsup
port.com");
WebRequest.KeepAlive = true;
WebRequest.ContentType = "application/x-www-form-urlencoded";
WebRequest.Method = "POST";
WebRequest.AllowAutoRedirect = false;

string Data = "anything=really&itdoesnot=matter&whatever=willfai l";
WebRequest.ContentLength = Data.Length;

System.IO.Stream RequestStream = WebRequest.GetRequestStream();
--------------------------

The error occurs on the last line of the above code with the following error
message:

System.EntryPointNotFoundException: Unable to find an entry point named
EnumerateSecurityPackagesW in DLL security.dll.
I''m stumped. Can anyone shed some light on this error? It happens on the
both computers that I''ve tested it on. Both are Win2K with .NET 1.1.

Thank you in advance,

--
Matt Sollars
ma**@hypersite.net
-------------------
The Hypersite Network
2002 N. Salisbury Blvd.
Suite C
Salisbury, Maryland 21801
T: 410.749.2000
F: 410.219.3400
http://www.hypersite.net

推荐答案

Hello Matt,

错误通常是由证书不匹配引起的。一般来说,一个

证书与安装了

证书的用户的用户ID相关联(这是证书用户);因此,只有在加载该用户配置文件时,证书才可用。


ASP.NET在machinename / aspnet帐户下运行。既然您可以在控制台应用程序和控制台应用程序中成功运行

代码使用您登录的

用户帐户,我建议您更改

machinel.config。您可以在machine.config中检查processmodel部分。
http://msdn.microsoft.com/library/en...cessmodelsecti

on.asp?frame = true


希望它有所帮助。


祝你好运,

Yanhong Huang

微软在线合作伙伴支持


安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有赋予任何权利。


--------------------

!来自:Matt Sollars < ma ** @ hypersite.net>

!主题:SSL上的HttpWebRequest

!日期:2003年8月13日星期三17:05:19 -0400
!行:53

!组织:Hypersite

!X-Priority:3

!X-MSMail-Priority:正常

!X-Newsreader:Microsoft Outlook Express 6.00.2800.1158

!X-MimeOLE:微软MimeOLE制作V6.00.2800.1165

!消息ID:< Ox ************* @ TK2MSFTNGP12.phx.gbl>

!新闻组:microsoft.public.dotnet.framework.aspnet

!NNTP-Posting-Host:207.204.29.22

!路径:cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl

!外部参照:cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167651

!X-Tomcat-NG:microsoft.public.dotnet.framework.aspnet



!我已经用尽所有其他途径解决了这个问题。任何帮助都是

!非常感谢。



!我正在通过HttpWebRequest对象执行简单的POST到SSL URL

!( https://)。我试过几个不同的地址没有

!运气。我已经尝试向

!ServicePointManager提供新的ICertificatePolicy。我收到的错误很奇怪

!它甚至在发送任何数据之前就已经发生了。



!注意:此代码在控制台应用程序中运行良好。它是从Web应用程序执行的,它失败了。

!时刻。我已经尝试了

!模仿也没有运气。



!----------- ---------------

!HttpWebRequest WebRequest =

!(HttpWebRequest)System.Net.WebRequest.Create(" htt ps://www.anywherewithsslsu

p

!port.com");

!WebRequest.KeepAlive = true;

!WebRequest.ContentType =" application / x-www-form-urlencoded";

!WebRequest.Method =" POST";

!WebRequest。 AllowAutoRedirect = false;



!string Data =" anything = really& itdoesnot = matter& whatever = willfai l";

! WebRequest.ContentLength = Data.Length;



!System.IO.Stream RequestStream = WebRequest.GetRequestStream();

! - ------------------------



!错误发生在最后一行以上代码如下

错误

!消息:



! System.EntryPointNotFoundException:无法在DLL security.dll中找到名为

!EnumerateSecurityPackagesW的入口点。





!我很难过。任何人都可以对这个错误有所了解吗?它发生在

!我测试过的两台计算机上。两者都是带有.NET 1.1的Win2K。



!提前谢谢你,



! - -

!Matt Sollars

!ma**@hypersite.net

! -------------------

!Hypersite网络

!2002 N. Salisbury Blvd.

!套房C

!马里兰州索尔兹伯里21801

!T:410.749.2000

!F:410.219.3400

http://www.hypersite.net







Hello Matt,

The error is often caused by mismatched certificate. Generally spekaing, a
certificate is associated with the user ID of the user who installed the
certificate (this is the certificate user); therefore, the certificate is
available only when that user profile is loaded.

ASP.NET is running under machinename/aspnet account. Since you could run
the code successfully in console app and console app use your logged on
user account, I suggest you change asp.net application running account in
machinel.config. You could check processmodel part in machine.config.
http://msdn.microsoft.com/library/en...cessmodelsecti
on.asp?frame=true

Hope it helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Matt Sollars" <ma**@hypersite.net>
!Subject: HttpWebRequest over SSL
!Date: Wed, 13 Aug 2003 17:05:19 -0400
!Lines: 53
!Organization: Hypersite
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <Ox*************@TK2MSFTNGP12.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.204.29.22
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP12.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167651
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!I''ve exhausted all other avenues with this problem. Any help would be
!greatly appreciated.
!
!I am performing a simple POST via a HttpWebRequest object to an SSL URL
!(https://). I have attempted this to several different addresses with no
!luck. I''ve tried to supply a new ICertificatePolicy to the
!ServicePointManager as well. The oddity of the error that I''m receiving is
!it''s happening before any data is even sent.
!
!Note: This code works wonderfully from within a console application. The
!moment it is executed from a web application, it fails. I''ve tried
!impersonation as well with no luck.
!
!--------------------------
!HttpWebRequest WebRequest =
!(HttpWebRequest)System.Net.WebRequest.Create("htt ps://www.anywherewithsslsu
p
!port.com");
!WebRequest.KeepAlive = true;
!WebRequest.ContentType = "application/x-www-form-urlencoded";
!WebRequest.Method = "POST";
!WebRequest.AllowAutoRedirect = false;
!
!string Data = "anything=really&itdoesnot=matter&whatever=willfai l";
!WebRequest.ContentLength = Data.Length;
!
!System.IO.Stream RequestStream = WebRequest.GetRequestStream();
!--------------------------
!
!The error occurs on the last line of the above code with the following
error
!message:
!
! System.EntryPointNotFoundException: Unable to find an entry point named
!EnumerateSecurityPackagesW in DLL security.dll.
!
!
!I''m stumped. Can anyone shed some light on this error? It happens on the
!both computers that I''ve tested it on. Both are Win2K with .NET 1.1.
!
!Thank you in advance,
!
!--
!Matt Sollars
!ma**@hypersite.net
! -------------------
!The Hypersite Network
!2002 N. Salisbury Blvd.
!Suite C
!Salisbury, Maryland 21801
!T: 410.749.2000
!F: 410.219.3400
!http://www.hypersite.net
!
!
!


谢谢Yanhong。


您的建议有效,但我不明白。我没有向远程服务器发送

证书。我也没在我的

本地机器上安装证书。控制台应用程序在一个帐户下工作,具有

管理员权限,但它可以在具有这些

权限的任何帐户下运行。我将本地machine.config文件的'processModel userName

属性更改为system它可以作为一个Web应用程序。


也许我对SSL的理解有点基础。我是否理解

通过SSL与服务器通信,需要一些证书(可信或

不是)?当我输入https地址时,我的浏览器会为我处理这个问题?如果

那么,如果我以非常有限的

用户身份登录,我的浏览器如何将其关闭?使用什么证书;值得信赖,自签名?我可以绕过

更改我的machine.config文件以使用系统用户创建一个

自签名证书并将其安装在具有

与默认机器用户(ASPNET)相同的权利?


我明白这一切都可能是这个领域的主题,可能会消耗

太多时间了。在那个问题上,如果你愿意请我参考一个或更多关于这些问题的资源,我将不胜感激。


再次感谢你的支持时间,艳红。


问候,


-

马特索拉斯
ma ** @ hypersite.net

-------------------

Hypersite网络

2002 N. Salisbury Blvd.

套房C

索尔兹伯里,马里兰州21801
T:410.749.2000

F:410.219.3400
http://www.hypersite.net


Yan-Hong Huang [MSFT]" < YH ***** @ online.microsoft.com>在消息中写道

新闻:lK ************** @ cpmsftngxa06.phx.gbl ...

你好马特,


错误通常是由证书不匹配引起的。一般来说,一个

证书与安装了

证书的用户的用户ID相关联(这是证书用户);因此,只有在加载该用户配置文件时,证书才可用。


ASP.NET在machinename / aspnet帐户下运行。既然您可以在控制台应用程序和控制台应用程序中成功运行

代码使用您登录的

用户帐户,我建议您更改

machinel.config。您可以在machine.config中检查processmodel部分。
http://msdn.microsoft.com/library/en...cessmodelsecti

on.asp?frame = true


希望它有所帮助。


祝你好运,

Yanhong Huang

微软在线合作伙伴支持


安全! - www.microsoft.com/security

发布是按原样提供的。没有保证,也没有授予任何权利。
Thank you, Yanhong.

Your suggestion worked, but I do not understand. I am not sending a
certificate to the remote server. Nor have I installed a certificate on my
local machine. The console application worked under an account with
Administrator privileges but it works under ANY account with those
privileges. I changed my local machine.config file''s processModel userName
attribute to "system" and it worked as a web application.

Maybe my understanding of SSL is a bit elementary. Am I to understand that
to communicate with a server via SSL, some certificate is needed (trusted or
not)? And my browser handles that for me when I enter a https address? If
so, how does my browser pull it off if I am logged on as a very restricted
user? What certificate is used; trusted, self-signed? Can I get around
changing my machine.config file to use a system user by creating a
self-signed certificate and installing it under a special account that has
the same rights as the default machine user (ASPNET)?

I understand that this all may be off-topic for this area and may consume
too much of your time. On that note, if you would please refer me to one or
more resources regarding these questions, I would greatly appreciate it.

Thank you again for your time, Yanhong.

Regards,

--
Matt Sollars
ma**@hypersite.net
-------------------
The Hypersite Network
2002 N. Salisbury Blvd.
Suite C
Salisbury, Maryland 21801
T: 410.749.2000
F: 410.219.3400
http://www.hypersite.net

"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
news:lK**************@cpmsftngxa06.phx.gbl...
Hello Matt,

The error is often caused by mismatched certificate. Generally spekaing, a
certificate is associated with the user ID of the user who installed the
certificate (this is the certificate user); therefore, the certificate is
available only when that user profile is loaded.

ASP.NET is running under machinename/aspnet account. Since you could run
the code successfully in console app and console app use your logged on
user account, I suggest you change asp.net application running account in
machinel.config. You could check processmodel part in machine.config.
http://msdn.microsoft.com/library/en...cessmodelsecti
on.asp?frame=true

Hope it helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! ¨C www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.


Hello Matt,


欢迎您。我很乐意得到帮助。 :)


为了回答你的问题,我认为我们需要从安全套接字层(SSL)握手的过程开始。

安全套接字层(SSL)协议使用公钥和对称密钥加密的组合。 SSL会话

始终以称为SSL握手的消息交换开始。握手允许服务器通过使用公钥技术向客户端验证

本身,然后允许客户端和服务器合作创建

对称密钥用于在随后的会话期间进行快速加密,解密和篡改检测。可选地,

握手还允许客户端向服务器验证自己。


有关详细信息,我建议您参考知识库文章描述安全套接字层(SSL)握手>

at http://support.microsoft.com/default...b;EN-US;257591

此外,有关其他信息,请参阅Microsoft知识库中的以下文章:

SSL握手期间客户端身份验证过程的说明
http://support.microsoft.com/default...b;EN-US;257586

SSL握手期间服务器身份验证过程的描述
http://support.microsoft.com /default...b;EN-US;257587

希望它有所帮助。


祝你好运,
Yanhong Huang

Microsoft在线合作伙伴支持


安全! - www.microsoft.com/security

此帖子原样是按原样提供的。没有保证,也没有赋予任何权利。


--------------------

!来自:Matt Sollars < ma ** @ hypersite.net>

!参考文献:< Ox ************* @ TK2MSFTNGP12.phx.gbl> < lK ************** @ cpmsftngxa06.phx.gbl>

!主题:Re:HttpWebRequest over SSL

!日期:星期四,2003年8月14日09:14:34 -0400

!行:66

!组织:Hypersite

!X-Priority: 3

!X-MSMail-Priority:正常

!X-Newsreader:Microsoft Outlook Express 6.00.2800.1158

!X-MimeOLE:制作由Microsoft MimeOLE V6.00.2800.1165

!消息ID:< uH ************** @ TK2MSFTNGP10.phx.gbl>

!新闻组:microsoft.public.dotnet.framework.aspnet

!NNTP-Posting-Host:207.204.29.22

!路径:cpmsftngxa06.phx.gbl! TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl

!外部参照:cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167847

!X- Tomcat-NG:microsoft.public.dotnet.framework.aspnet



!谢谢Yanhong。



!你的建议有效,但我不明白。我没有向远程服务器发送

!证书。我也没有在我的

!本地机器上安装证书。控制台应用程序在一个帐户下工作,具有

!管理员权限,但它可以在任何帐户下使用这些

!权限。我将本地machine.config文件的'processModel userName

!属性更改为" system"它作为一个Web应用程序工作。



!也许我对SSL的理解有点基础。我是否理解

!通过SSL与服务器通信,需要一些证书(可信或

!不是)?当我输入https地址时,我的浏览器会为我处理这个问题?如果

!那么,如果我以非常有限的

!用户身份登录,我的浏览器如何将其关闭?使用什么证书;值得信赖,自签名?我可以绕过

!更改我的machine.config文件以使用系统用户创建一个

!自签名证书并将其安装在一个具有<的特殊帐户下br />
!与默认机器用户(ASPNET)相同的权利?



!我明白这一切都可能是偏离主题的区域和可能会消耗

!你的时间太多了。在那个注意事项上,如果您愿意,请将我推荐给一个或者更多关于这些问题的资源,我将不胜感激。



!再次感谢Yanhong的时间。



!问候,



! - -

!Matt Sollars

!ma**@hypersite.net

! -------------------

!Hypersite网络

!2002 N. Salisbury Blvd.

!套房C

!马里兰州索尔兹伯里21801

!T:410.749.2000

!F:410.219.3400

http://www.hypersite.net







!Yan-Hong Huang [MSFT]" < YH ***** @ online.microsoft.com>在消息中写道

!新闻:lK ************** @ cpmsftngxa06.phx.gbl ...

!你好马特,



!错误通常是由证书不匹配引起的。一般来说,一个

!证书与安装了

!证书的用户的用户ID相关联(这是证书用户);因此,证书是

!仅在加载该用户配置文件时可用。



!ASP.NET在machinename / aspnet下运行帐户。既然您可以运行

!代码在控制台应用和控制台应用程序中成功使用您登录的

!用户帐户,我建议您更改运行帐户中的asp.net应用程序br />
!machinel.config。你可以检查machine.config中的processmodel部分。

http://msdn.microsoft.com/library/en...cessmodelsecti

!on.asp?frame = true



!希望它有所帮助。



!祝你好运,

!Yanhong Huang

!Microsoft在线合作伙伴支持



!安全! - www.microsoft.com/security

!该帖子是按原样提供的。没有保证,也没有权利。






Hello Matt,

You are welcome. I am glad to be of assistance. :)

To answer your qeuestion, I think we need to start from the process of the Secure Sockets Layer (SSL) Handshake. The
Secure Sockets Layer (SSL) protocol uses a combination of public-key and symmetric-key encryption. An SSL session
always begins with an exchange of messages called the SSL handshake. The handshake allows the server to authenticate
itself to the client by using public-key techniques, and then allows the client and the server to cooperate in the creation of
symmetric keys used for rapid encryption, decryption, and tamper detection during the session that follows. Optionally, the
handshake also allows the client to authenticate itself to the server.

For details, I suggest you refer to KB article "Description of the Secure Sockets Layer (SSL) Handshake"
at http://support.microsoft.com/default...b;EN-US;257591

Also, For additional information, refer to the following articles in the Microsoft Knowledge Base:
Description of the Client Authentication Process During the SSL Handshake
http://support.microsoft.com/default...b;EN-US;257586
Description of the Server Authentication Process During the SSL Handshake
http://support.microsoft.com/default...b;EN-US;257587

Hope it helps.

Best regards,
Yanhong Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
!From: "Matt Sollars" <ma**@hypersite.net>
!References: <Ox*************@TK2MSFTNGP12.phx.gbl> <lK**************@cpmsftngxa06.phx.gbl>
!Subject: Re: HttpWebRequest over SSL
!Date: Thu, 14 Aug 2003 09:14:34 -0400
!Lines: 66
!Organization: Hypersite
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
!Message-ID: <uH**************@TK2MSFTNGP10.phx.gbl>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 207.204.29.22
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:167847
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Thank you, Yanhong.
!
!Your suggestion worked, but I do not understand. I am not sending a
!certificate to the remote server. Nor have I installed a certificate on my
!local machine. The console application worked under an account with
!Administrator privileges but it works under ANY account with those
!privileges. I changed my local machine.config file''s processModel userName
!attribute to "system" and it worked as a web application.
!
!Maybe my understanding of SSL is a bit elementary. Am I to understand that
!to communicate with a server via SSL, some certificate is needed (trusted or
!not)? And my browser handles that for me when I enter a https address? If
!so, how does my browser pull it off if I am logged on as a very restricted
!user? What certificate is used; trusted, self-signed? Can I get around
!changing my machine.config file to use a system user by creating a
!self-signed certificate and installing it under a special account that has
!the same rights as the default machine user (ASPNET)?
!
!I understand that this all may be off-topic for this area and may consume
!too much of your time. On that note, if you would please refer me to one or
!more resources regarding these questions, I would greatly appreciate it.
!
!Thank you again for your time, Yanhong.
!
!Regards,
!
!--
!Matt Sollars
!ma**@hypersite.net
! -------------------
!The Hypersite Network
!2002 N. Salisbury Blvd.
!Suite C
!Salisbury, Maryland 21801
!T: 410.749.2000
!F: 410.219.3400
!http://www.hypersite.net
!
!
!
!"Yan-Hong Huang[MSFT]" <yh*****@online.microsoft.com> wrote in message
!news:lK**************@cpmsftngxa06.phx.gbl...
!Hello Matt,
!
!The error is often caused by mismatched certificate. Generally spekaing, a
!certificate is associated with the user ID of the user who installed the
!certificate (this is the certificate user); therefore, the certificate is
!available only when that user profile is loaded.
!
!ASP.NET is running under machinename/aspnet account. Since you could run
!the code successfully in console app and console app use your logged on
!user account, I suggest you change asp.net application running account in
!machinel.config. You could check processmodel part in machine.config.
!http://msdn.microsoft.com/library/en...cessmodelsecti
!on.asp?frame=true
!
!Hope it helps.
!
!Best regards,
!Yanhong Huang
!Microsoft Online Partner Support
!
!Get Secure! ¨C www.microsoft.com/security
!This posting is provided "AS IS" with no warranties, and confers no rights.
!
!
!


这篇关于通过SSL的HttpWebRequest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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