나는 서비스와 함께 모바일과 데스크탑 사이에서뿐만 아니라 통신하는 비슷한 프로젝트를 가지고있다.
EXE의 Authenticode 인증서를 사용하여 요청을 처리하는 바이너리인지 확인합니다.
요청한 쪽 (게시물 단순화 이상).우리는 URL의를하려고하는 자들을 원하는대로
Module m = Assembly.GetEntryAssembly().GetModules()[0];
using (var cert = m.GetSignerCertificate())
using (var cert2 = new X509Certificate2(cert))
{
var _clientHandler = new HttpClientHandler();
_clientHandler.ClientCertificates.Add(cert2);
_clientHandler.ClientCertificateOptions = ClientCertificateOption.Manual;
var myModel = new Dictionary<string, string>
{
{ "property1","value" },
{ "property2","value" },
};
using (var content = new FormUrlEncodedContent(myModel))
using (var _client = new HttpClient(_clientHandler))
using (HttpResponseMessage response = _client.PostAsync($"{url}/{controler}/{action}", content).Result)
{
response.EnsureSuccessStatusCode();
string jsonString = response.Content.ReadAsStringAsync().Result;
var json = new Newtonsoft.Json.JsonSerializer();
var myClass = JsonConvert.DeserializeObject<MyClass>(json);
}
}
나는 다음 잘못된 요청을보다는 얻을
X509Certificate2 clientCertInRequest = Request.HttpContext.Connection.ClientCertificate;
if (!clientCertInRequest.Verify() || !AllowedCerialNumbers(clientCertInRequest.SerialNumber))
{
Response.StatusCode = 404;
return null;
}
우리는 오히려 500보다 404을 제공하는 요청을 받으면 작업에 다음 코드를 사용하여 그 (것)들이 "바른 길에"다는 것을 알게하십시오
woha 친구가되어 주셨습니다. 도와 주셔서 정말 고마워요. 요즘 나는 휴가를 떠났다. –
나는 호기심있다. 리눅스 머신이나 윈도우에서이 작업을 수행 했습니까? – Steven
Windows (10)과 Linux (Mint 17.3, 18 및 18.1)에서 모두 작업하고 있습니다. 비공개 키없이 인증서를 사용하려고하면 "SSL 연결 오류"(CURLE_SSL_CONNECT_ERROR 35)가 발생했습니다. – yfisaqt