请求已中止:无法创建SSL / TLS安全通道(The request was aborted: Could not create SSL/TLS secure channel)
由于此错误消息,我们无法使用
WebRequest
连接到HTTPS服务器:
The request was aborted: Could not create SSL/TLS secure channel.
我们知道服务器没有使用所使用路径的有效的HTTPS证书,但为了避免这个问题,我们使用我们从另一个StackOverflow文章中获取的以下代码:
private void Somewhere() { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AllwaysGoodCertificate); } private static bool AllwaysGoodCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) { return true; }
问题是服务器永远不会验证证书,并且失败并出现上述错误。 有人有什么想法应该怎么办?
我应该提到一个同事和我在几个星期前进行了测试,它的工作正常,类似于我上面写的内容。 我们发现的唯一的“主要区别”就是我使用的是Windows 7,而他正在使用Windows XP。 这会改变什么吗?
We are unable to connect to an HTTPS server using
WebRequest
because of this error message:
The request was aborted: Could not create SSL/TLS secure channel.
We know that the server doesn't have a valid HTTPS certificate with the path used, but to bypass this issue, we use the following code that we've taken from another StackOverflow post:
private void Somewhere() { ServicePointManager.ServerCertificateValidationCallback += new RemoteCertificateValidationCallback(AlwaysGoodCertificate); } private static bool AlwaysGoodCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors policyErrors) { return true; }
The problem is that server never validates the certificate and fails with the above error. Does anyone have any idea of what should I do?
I should mention that a colleague and I performed tests a few weeks ago and it was working fine with something similar to what I wrote above. The only "major difference" we've found is that I'm using Windows 7 and he was using Windows XP. Does that change something?
原文:https://stackoverflow.com/questions/2859790
最满意答案
您需要添加一个起始锚点
^
:^\d{4}$
您的正则表达式
\d{4}$
将匹配以4位数字结尾的字符串。 所以输入如-1234
将被接受。通过添加起始锚点,您只匹配那些以4位数字开头和结尾的字符串,这意味着它们必须只包含4位数字。
You need to add a start anchor
^
as:^\d{4}$
Your regex
\d{4}$
will match strings that end with 4 digits. So input like-1234
will be accepted.By adding the start anchor you match only those strings that begin and end with 4 digits, which effectively means they must contain only 4 digits.
相关问答
更多-
这不是正则表达式的适当用法。 你最好使用 [0-9]{2}/[0-9]{2}/[0-9]{4} 然后检查更高级语言的范围。 This is not an appropriate use of regular expressions. You'd be better off using [0-9]{2}/[0-9]{2}/[0-9]{4} and then checking ranges in a higher-level language.
-
您需要添加一个起始锚点^ : ^\d{4}$ 您的正则表达式\d{4}$将匹配以4位数字结尾的字符串。 所以输入如-1234将被接受。 通过添加起始锚点,您只匹配那些以4位数字开头和结尾的字符串,这意味着它们必须只包含4位数字。 You need to add a start anchor ^ as: ^\d{4}$ Your regex \d{4}$ will match strings that end with 4 digits. So input like -1234 will be accep ...
-
什么正则表达式将匹配有效的国际电话号码?(What regular expression will match valid international phone numbers?)[2023-08-17]
\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d| 2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]| 4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$ 是用于匹配通用国际电话号码的正确格式。 我以国际接入码标识符'+'取代了以美国陆地线为中心的国际接入码011,这是强制性的。 我也将国家的最低数字改为至少一位数。 请注意,如果您将此格式的数字输入 ... -
您如何仅使用正则表达式匹配有效的罗马数字?(How do you match only valid roman numerals with a regular expression?)[2022-06-07]
尝试: ^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$ 打破它: M{0,4} 这指定了数千个部分,并且基本上将其限制在0到4000之间。 这是比较简单的: 0:matched by M{0} 1000: M matched by M{1} 2000: MM matched by M{2} 3000: MMM matched by M{3} 4000: MMMM matc ... -
如果我理解正确,你想要的是"[A-Za-z]{3}[0-9]{4}"之前和之后的单词边界 。 如果在字符串的开头或结尾有匹配项,或者在它之前或之后有标点符号(或者你不想以。结尾,因为它匹配字符串,那么将它包装在空格字符( \s )中将不起作用abc12345 )。 尝试这个: @"\b[A-Za-z]{3}[0-9]{4}\b" ( @你不必逃避你在表达式中使用的每个\ ) If I understand you correctly, what you want is a word boundary bef ...
-
我来了 .(method)\s*\((?![\"\'](abc|bbc|abc bbc|der|der abc)[\"\']) 所以我只是将'和'移出这个(x | x | x)组,以使事情变得更清晰 另外 - 您可以添加/ g修饰符进行测试,并将所有数据放入文本框中。 这里的链接: https : //regex101.com/r/oT4nN3/1 i've came with .(method)\s*\((?![\"\'](abc|bbc|abc bbc|der|der abc)[\"\']) so ...
-
通过消除过程,我找到了一个解决方案。 首先,我在表达式的部分确定了问题。 所以我把它从我的表达中撕掉,然后慢慢地添加一些东西,直到我得到同样的错误。 导致问题的原因是? 。 表达式仍然没有? 即使CDATA内部没有任何内容。 我不确定1)为什么我得到那个模式的人包括它,2)为什么xsd不能在我的模式中允许它? By process of elimination I was able to find a fix. First I determined that the p ...
-
为什么在这个看似有效的正则表达式中进行灾难性的回溯?(why catastrophic backtracking in this seemingly valid regular expression?)[2023-06-17]
^1\.(.+?)\n2\.(.+?)\n3\.(.+?)\n4\.(.+?)\n5\.(.+?)$ 这是为我工作。只需从最终和开始删除无用的* 。使用multiline标志。请参阅演示。 https://regex101.com/r/fM9lY3/34 ^1\.(.+?)\n2\.(.+?)\n3\.(.+?)\n4\.(.+?)\n5\.(.+?)$ This is working for me.Just remove the useless * from end and beginning.use ... -
您可以使用Date.getFullYear()方法。 var d = new Date("Fri Dec 01 1999 00:00:00 GMT-0800 (Pacific Standard Time)"); var year = d.getFullYear(); You can use Date.getFullYear() method. var d = new Date("Fri Dec 01 1999 00:00:00 GMT-0800 (Pacific Standard Time)"); var ...
-
使用new RegExp构造函数时,需要正确转义字符串。 由于您的模式中没有任何变量,请尝试 var str1 = "AAbb123."; var str2 = "ell"; var re = /^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[\\\+\=\.\[\]_£|\`¬':\;\~{}<>()#?!\@$\%^&*-]).{8,20}$/; if(str1.match(re)){ alert("matched") } else { ...