首页 新闻 会员 周边 捐助

netcore ubuntu 上运行出错

0
悬赏园豆:5 [待解决问题]
复制代码
 1 using System;
 2 using System.IO;
 3 using System.Net;
 4 using System.Net.Mail;
 5 using System.Text;
 6 
 7 namespace JKABC
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             string kvm1 = Action("https://abc.html:1500/vmmgr?out=json");
14             int kvm1r = kvm1.IndexOf("running");
15             int kwm1s = kvm1.IndexOf("vmstatus");
16             if (kwm1s != -1)
17             {
18                 if (kvm1r == -1)
19                 {
20                     try
21                     {
22                         Action("https://abc.html:1500/vmmgr?out=jsonelid=178");
23                         sendemall("kvm1重启成功", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
24                     }
25                     catch
26                     {
27                         sendemall("kvm1重启失败", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
28                     }
29                 }
30             }
31 
32             string kvm2 = Action("https://abc2.html:1500/vmmgr?out=json");
33             int kvm2r = kvm2.IndexOf("running");
34             int kwm2s = kvm2.IndexOf("vmstatus");
35             if (kwm2s != -1)
36             {
37                 if (kvm2r == -1)
38                 {
39                     try
40                     {
41                         Action("https://abc2.html:1500/vmmgr?out=json&elid=223");
42                         sendemall("kvm2重启成功", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
43                     }
44                     catch
45                     {
46                         sendemall("kvm2重启失败", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
47                     }
48                 }
49             }
50             Console.WriteLine("Hello World!");
51         }
52         static string Action(string url)
53         {
54             HttpWebRequest httpWebRequest;
55             HttpWebResponse webResponse;
56             Stream getStream;
57             StreamReader streamReader;
58             string getString = "";
59             httpWebRequest = (HttpWebRequest)HttpWebRequest.Create(url);
60             CookieContainer co = new CookieContainer();
61             httpWebRequest.CookieContainer = co;
62             httpWebRequest.Method = "GET";
63             webResponse = (HttpWebResponse)httpWebRequest.GetResponse();
64             getStream = webResponse.GetResponseStream();
65             streamReader = new StreamReader(getStream, Encoding.Default);
66             getString = streamReader.ReadToEnd();
67             streamReader.Close();
68             getStream.Close();
69             return getString;
70         }
71         static void sendemall(string title, string context)
72         {
73             SmtpClient client = new SmtpClient("smtp.aliyun.com");
74             client.UseDefaultCredentials = false;
75             client.Credentials = new System.Net.NetworkCredential("aaa@aliyun.com", "aaaaaa");
76             client.DeliveryMethod = SmtpDeliveryMethod.Network;
77             MailMessage message = new MailMessage("bbbbbb@aliyun.com", "12dddd8@qq.com", title, context);
78             message.Sender = new MailAddress("aaa@aliyun.com");
79             message.BodyEncoding = System.Text.Encoding.UTF8;
80             message.IsBodyHtml = true;
81             client.Send(message);
82         }
83     }
84 }
复制代码
View Code

代码里面的邮箱和网页进行了修改,但是正确的地址和邮箱在win平台测试通过的。希望大神帮忙看下是什么原因。错误截图如下:

等待冰柠檬的主页 等待冰柠檬 | 初学一级 | 园豆:35
提问于:2018-02-09 20:19

错误信息: "System.Net.Http.CurlException: SSL peer certificate or SSH remote key was not OK"

dudu 6年前
< >
分享
所有回答(1)
0

运行openssl version看一下openssl的版本

dudu | 园豆:29732 (高人七级) | 2018-02-09 20:50

OpenSSL 1.0.1f 6 Jan 2014

支持(0) 反对(0) 等待冰柠檬 | 园豆:35 (初学一级) | 2018-02-09 21:00

是openssl的问题?

支持(0) 反对(0) 等待冰柠檬 | 园豆:35 (初学一级) | 2018-02-09 21:01

@等待冰柠檬: 应该与https证书有关,curl https://abc.html:1500/vmmgr?out=json能正常访问吗?

支持(0) 反对(0) dudu | 园豆:29732 (高人七级) | 2018-02-09 21:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册