我想将一些数据发布到https服务器,之后我需要添加客户端证书以进行信任验证。我已经在C#中完成了它,如下所示: -
X509Certificate cert = X509Certificate.CreateFromCertFile("Path to my .cer file"); //****** name of cer file is "ServerTrial.cer" ******//
Uri authURL = new Uri("https://myServer/post");
HttpWebRequest authRequest = (HttpWebRequest)WebRequest.Create(authURL); //****** Here i add the server url ******//
authRequest.ClientCertificates.Add(cert); //****** Here i add the client certificate ******//
authRequest.Method = "POST"; //****** Here i specify the method which is "POST" ******//
byte[] postBytes = "Data to be posted";
authRequest.ContentLength = postBytes.Length;
Stream requestStream = authRequest.GetRequestStream();
// now send it
requestStream.Write(postBytes, 0, postBytes.Length); //****** Here I post the data to the Server ******//
requestStream.Close();
// grab the response
HttpWebResponse response = (HttpWebResponse)authRequest.GetResponse();
StreamReader responseStream = new StreamReader(response.GetResponseStream());
string responseStr = responseStream.ReadToEnd();
所以最终我想要的是创建一个http对象,向其添加服务器URL,向其添加客户端证书,然后最终将数据发布到服务器。 现在我想在C ++中实现上述目标。我想在上面使用openSSL,但我对它的想法很少。任何人都可以指导我这个吗?
- 谢谢大家, sattu