我试图从asp.net的角度检查客户端在尝试与我的应用程序交互时使用的安全协议.我有不同的应用程序托管asp.net Web应用程序,asmx webservices,asp.net mvc,wcf服务.请建议我如何通过ssl/tls协议知道请求.
我的目的是告诉我的应用程序用户使用tls而不是因为poodle漏洞而使用ssl3.
我正在使用 RestSharp 与 UPS API 对话。
我有 POSTMAN,我可以很好地与 API 对话,但是当我将其移植到 c# 时,我得到了一个空值的response.Content。
private void button2_Click(object sender, EventArgs e)
{
label1.Text = CustomerName;
MessageBox.Show(username);
MessageBox.Show(password);
MessageBox.Show(Lic);
try
{
var client = new RestClient("https://wwwcie.ups.com/rest/Track");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "73a23cf5-558a-9a83-ec80-4a224b35351a");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\r\n \"UPSSecurity\": {\r\n \"UsernameToken\": {\r\n \"Username\": " + username + ",\r\n \"Password\": " + password + "\r\n },\r\n \"ServiceAccessToken\": {\r\n \"AccessLicenseNumber\": " + Lic + "\r\n }\r\n },\r\n \"TrackRequest\": {\r\n \"Request\": {\r\n \"RequestAction\": \"Track\",\r\n \"RequestOption\": \"activity\"\r\n …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取我的salesforcePartialbox的会话ID。
我的代码:
curl https://test.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=definitely the correct client id" -d "client_secret=definitely the correct client secret" -d "username=mymail@mail.com.partialbox" -d "password=passandsecuritytoken"
Run Code Online (Sandbox Code Playgroud)
我还做了什么:
我仍然遇到错误{"error":"invalid_grant","error_description":"authentication failure"}。
我搜索了SF论坛和StackOverflow问题,但找不到任何解决方案。有人知道吗,这里还有什么问题?
我有一个在 VB.net 中编码的应用程序,它具有这种访问 Webservice 的方法,我遇到了这个错误,在搜索修复程序后我仍然没有运气。
错误:请求被中止:无法创建 SSL/TLS 安全通道。
'ServicePointManager.Expect100Continue = False
'ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls
Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest)
Dim ErrMsg As String = String.Empty
Try
Dim response As WebResponse = request.GetResponse()
Using responseStream As Stream = response.GetResponseStream()
Dim reader As New StreamReader(responseStream, Encoding.UTF8)
Return reader.ReadToEnd()
End Using
Catch ex As WebException
ErrMsg = ex.Message.ToString
MsgBox(ErrMsg)
Dim errorResponse As WebResponse = ex.Response
Using responseStream As Stream = errorResponse.GetResponseStream()
Dim reader As New StreamReader(responseStream, Encoding.GetEncoding("utf-8"))
' log errorText
Dim …Run Code Online (Sandbox Code Playgroud) 我正在尝试执行以下代码。这些错误是不言自明的,但仅在远程运行时发生。在本地运行时,所有代码都可以正常工作,我可以通过从需要Tls12的Web服务器中提取内容并在未更改安全协议的情况下收到错误来验证它们是否具有预期的效果。
$tls12 = [Enum]::ToObject([Net.SecurityProtocolType], 3072)
[Net.ServicePointManager]::SecurityProtocol = $tls12
Run Code Online (Sandbox Code Playgroud)
在服务器上运行时,它们可以完美执行。通过Invoke-Command远程运行时,出现此错误。
Exception setting "SecurityProtocol": "The requested security protocol
is not supported."
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
+ PSComputerName : servername
Run Code Online (Sandbox Code Playgroud)
或者,这行代码从根本上是相同的。
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Run Code Online (Sandbox Code Playgroud)
直接在服务器上运行时,此方法也有效,但在远程运行时,会导致此错误。
Exception setting "SecurityProtocol": "Cannot convert null to type
"System.Net.SecurityProtocolType" due to invalid enumeration values. Specify one of the following enumeration values and
try again. The possible enumeration values are "Ssl3, Tls"."
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : …Run Code Online (Sandbox Code Playgroud) 在配置 TFS vNext 构建代理时,我收到错误消息:
ErrorConnectingToTheServer 发送请求时出错。请求。
我在事件日志或其他任何地方都找不到任何其他错误消息。
请帮忙。
更新 1:SSL (https///tfs)不起作用。但是普通的 http:// 起作用了。
更新 2:我已删除旧代理并尝试配置新代理。这样做时,我收到了 _diag 文件夹中存在的以下错误:
System.Net.WebException:基础连接已关闭:发送时发生意外错误。---> System.IO.IOException: 无法从传输连接读取数据:远程主机强行关闭了现有连接。---> System.Net.Sockets.SocketException:远程主机强行关闭了现有连接.... System.Net.WebException:底层连接已关闭:发送时发生意外错误。---> System.IO.IOException: 无法从传输连接读取数据:远程主机强行关闭了现有连接。---> System.Net.Sockets.SocketException: 一个现有的连接被远程主机强行关闭.... System.IO.IOException: 无法从传输连接读取数据:一个现有的连接被远程主机强行关闭主持人。
更新 3: 我有两台服务器,如下所示:1 是应用程序服务器,其他是 SharePoint 和报告服务器,试图在第三台服务器中配置构建。TFS URL 配置了 SSL 443。
如果我尝试使用http://tfs server/tfs配置代理,它会成功,但在构建时收到错误。当我尝试使用 https 进行配置时,出现上述错误。有趣的是,我曾将这台服务器用于两个代理,在那种情况下,我又多了一台服务器,我发现错误工作正常。
当我尝试从 morizon.pl 下载源页面时遇到问题:
WebClient webClient = new WebClient();
try
{
string str = webClient.DownloadString("https://www.morizon.pl/");
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Run Code Online (Sandbox Code Playgroud)
我在 stackoverflow 中检查了类似的问题并编辑了我的代码,但仍然没有,我被这个问题困住了。
public class CookieAwareWebClient : WebClient
{
public CookieContainer CookieContainer { get; set; }
public CookieAwareWebClient()
: this(new CookieContainer())
{ }
public CookieAwareWebClient(CookieContainer c)
{
this.CookieContainer = c;
}
protected override WebRequest GetWebRequest(Uri address)
{
WebRequest request = base.GetWebRequest(address);
var castRequest = request as HttpWebRequest;
if (castRequest != null)
{
castRequest.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";
castRequest.UserAgent = "Mozilla/5.0 (Windows …Run Code Online (Sandbox Code Playgroud) YouTube 最近推出了句柄功能,他们为用户提供了 youtube.com/@xxx 类型的用户名,当访问这些 URL 时会显示用户的频道,但我在 API 存储库中找不到任何文档或参考。
如何从 YouTube 用户的句柄中提取频道 ID?
我禁用了 TLS 1.0。因此,我们尝试在使用 .Net Framework 4.0 的 .Net 应用程序中使用 TLS 1.2。
我在开始时添加了此代码
System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;
Run Code Online (Sandbox Code Playgroud)
它在我的本地系统上完美运行。
但我不确定为什么当我在服务器(Windows Server 2008 R2)上部署代码时它不起作用。我检查了一切。服务器上存在.Net框架。但它仍然只在服务器上给出同样的问题。
我在这里缺少什么吗?
asp.net-mvc .net-4.0 windows-server-2008-r2 aaa-security-protocol tls1.2
假设我有一个标准的.NET(4.5)Web应用程序需要使用TLS连接到安全服务器.
我想停止在我的服务器中支持未使用或弱的协议和密码套件,并且只支持客户端也支持的协议(最好是TLS 1.2)
使用的TLS(1.0,1.1或1.2)和/或密码套件的版本是否取决于操作系统或.NET版本?
换句话说,当我的.NET应用程序安装在具有不同操作系统/更新的计算机上时,它是否会使用不同的密码套件或TLS版本?或者.NET 4.5的使用是否确保每个客户端 - 服务器通信上的协议都是相同的?