diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac index 083cc69..63b3f1a 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.AccountDB.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPMeta.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPMeta.dacpac index 1380e40..ae6e36f 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPMeta.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPMeta.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac index 5e37354..d8fdfeb 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac index 4ccf6d5..cdcfd6a 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.CPXV2Log.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac index 2ec36d3..e0c4527 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.UniqueKeyDB.dacpac differ diff --git a/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac b/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac index 8bdc1ac..c15185c 100644 Binary files a/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac and b/DBPatch/sqlScripts/dacpac/SystemX.DB.VPKI_DataDB.dacpac differ diff --git a/Projects/Config/WebApi.Project.ProxyKMSApi.Config.json b/Projects/Config/WebApi.Project.ProxyKMSApi.Config.json index de01923..ef00bc3 100644 --- a/Projects/Config/WebApi.Project.ProxyKMSApi.Config.json +++ b/Projects/Config/WebApi.Project.ProxyKMSApi.Config.json @@ -7,6 +7,11 @@ "API": [ { "ApiName": "kms", + "CertificateVerify": false, + "CertPemPath": "D:\\00_Download\\[MDS인텔리전스] 시스템액스 인증서_2026027\\SystemX-SHM_cert.pem", + "CertKeyPath": "D:\\00_Download\\[MDS인텔리전스] 시스템액스 인증서_2026027\\SystemX-SHM_cert.key", + //"CertPemPath": "D:\\00_Download\\[MDS인텔리전스] 시스템액스 인증서_20260129\\SystemX-SHM_cert.pem", + //"CertKeyPath": "D:\\00_Download\\[MDS인텔리전스] 시스템액스 인증서_20260129\\SystemX-SHM_cert.key", "Functions": [ { "Name": "EcuID_SupplierEcuID", diff --git a/Projects/DLL/SystemX.Core.DB.dll b/Projects/DLL/SystemX.Core.DB.dll index 9575ca7..5bbe3f6 100644 Binary files a/Projects/DLL/SystemX.Core.DB.dll and b/Projects/DLL/SystemX.Core.DB.dll differ diff --git a/Projects/DLL/SystemX.Core.dll b/Projects/DLL/SystemX.Core.dll index 6413124..3049e78 100644 Binary files a/Projects/DLL/SystemX.Core.dll and b/Projects/DLL/SystemX.Core.dll differ diff --git a/Projects/NetStandard/KeficoMailService.zip b/Projects/NetStandard/KeficoMailService.zip new file mode 100644 index 0000000..c42bc1d Binary files /dev/null and b/Projects/NetStandard/KeficoMailService.zip differ diff --git a/Projects/NetStandard/KeficoMailService/Address.cs b/Projects/NetStandard/KeficoMailService/Address.cs new file mode 100644 index 0000000..2d7ccd4 --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/Address.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KeficoMailService +{ + public class Address + { + public string AddressMail { get; set; } = string.Empty; + public string AddressName { get; set; } = string.Empty; + } +} diff --git a/Projects/NetStandard/KeficoMailService/HtmlFormType.cs b/Projects/NetStandard/KeficoMailService/HtmlFormType.cs new file mode 100644 index 0000000..d46a613 --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/HtmlFormType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KeficoMailService +{ + public class HtmlFormType + { + public string FormType { get; set; } = string.Empty; + public string SystemName { get; set; } = string.Empty; + } +} diff --git a/Projects/NetStandard/KeficoMailService/KeficoMailService.csproj b/Projects/NetStandard/KeficoMailService/KeficoMailService.csproj new file mode 100644 index 0000000..66470e7 --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/KeficoMailService.csproj @@ -0,0 +1,51 @@ + + + + + Debug + AnyCPU + {63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7} + Library + Properties + KeficoMailService + KeficoMailService + v4.8.1 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Projects/NetStandard/KeficoMailService/MailType.cs b/Projects/NetStandard/KeficoMailService/MailType.cs new file mode 100644 index 0000000..af123e9 --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/MailType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KeficoMailService +{ + public enum MailType + { + Text, + Html + } +} diff --git a/Projects/NetStandard/KeficoMailService/Manager.cs b/Projects/NetStandard/KeficoMailService/Manager.cs new file mode 100644 index 0000000..093d9cb --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/Manager.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Runtime.Remoting.Messaging; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace KeficoMailService +{ + public class Manager + { + public string Host { get; set; } = "https://service.kefico.co.kr"; + + public readonly string GetFormHTML = "/KEFICO.XML/MAIL/MailManager.asmx"; + public readonly string SendMailDetailHTML = "/KEFICO.XML/MAIL/MailManager.asmx"; + + public string GetFormHtml(HtmlFormType formType) + { + string result = string.Empty; + string url = $"{Host}{GetFormHTML}"; + + string soapEnvelope = $@" + + + + + {formType.SystemName} + {formType.FormType} + + + +"; + + Console.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine($"Request URL: {url}"); + Console.WriteLine($"Request soap: {soapEnvelope}"); + + byte[] data = Encoding.UTF8.GetBytes(soapEnvelope); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + request.Method = "POST"; + request.ContentType = "application/soap+xml; charset=utf-8"; + request.ContentLength = data.Length; + + using (Stream stream = request.GetRequestStream()) + { + stream.Write(data, 0, data.Length); + } + + using (WebResponse response = request.GetResponse()) + using (StreamReader reader = new StreamReader(response.GetResponseStream())) + { + result = reader.ReadToEnd(); + + //decode + XDocument doc = XDocument.Parse(result); + + XNamespace ns = "http://kefico.co.kr/"; + + string htmlEncoded = + doc.Descendants(ns + "GetFormHTMLResult").First().Value; + + // HTML Decode + + result = WebUtility.HtmlDecode(htmlEncoded); + result = WebUtility.HtmlDecode(htmlEncoded); + + Console.ForegroundColor = ConsoleColor.DarkGreen; + Console.WriteLine(""); + Console.WriteLine("Response"); + Console.WriteLine(result); + } + + return result; + } + + public string SendMailDetail(Address from, List
to, List
cc, List
bcc, string subject, string body, MailType type) + { + string result = string.Empty; + string url = $"{Host}{SendMailDetailHTML}"; + + string soapEnvelope = $@" + + + + + {from.AddressMail} + {from.AddressName} + + {string.Join("",to.Select(x=> $@" +
+ {x.AddressMail} + {x.AddressName} +
"))} +
+ {string.Join("",cc.Select(x => $@" +
+ {x.AddressMail} + {x.AddressName} +
"))} +
+ {string.Join("", bcc.Select(x => $@" +
+ {x.AddressMail} + {x.AddressName} +
"))} +
+ {subject} + {body} + {type.ToString()} +
+
+
"; + + Console.ForegroundColor = ConsoleColor.DarkYellow; + Console.WriteLine(""); + Console.WriteLine($"Request URL: {url}"); + Console.WriteLine($"Request soap: {soapEnvelope}"); + + byte[] data = Encoding.UTF8.GetBytes(soapEnvelope); + + HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); + request.Method = "POST"; + request.ContentType = "application/soap+xml; charset=utf-8"; + request.ContentLength = data.Length; + + using (Stream stream = request.GetRequestStream()) + { + stream.Write(data, 0, data.Length); + } + + using (WebResponse response = request.GetResponse()) + using (StreamReader reader = new StreamReader(response.GetResponseStream())) + { + result = reader.ReadToEnd(); + + //decode + XDocument doc = XDocument.Parse(result); + + XNamespace ns = "http://kefico.co.kr/"; + + string htmlEncoded = + doc.Descendants(ns + "SendMailDetailResponse").First().Value; + + //decode + result = WebUtility.HtmlDecode(htmlEncoded); + result = WebUtility.HtmlDecode(result); + + Console.ForegroundColor = ConsoleColor.DarkGreen; + Console.WriteLine(""); + Console.WriteLine("Response"); + Console.WriteLine(result); + } + + return result; + } + } +} diff --git a/Projects/NetStandard/KeficoMailService/Properties/AssemblyInfo.cs b/Projects/NetStandard/KeficoMailService/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f0a1b20 --- /dev/null +++ b/Projects/NetStandard/KeficoMailService/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("KeficoMailService")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("KeficoMailService")] +[assembly: AssemblyCopyright("Copyright © 2026")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("63ff04ee-d1a5-4406-9267-1ee1e9fbb9e7")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Projects/NetStandard/NetStandard.sln b/Projects/NetStandard/NetStandard.sln index 607f8e6..5f566c4 100644 --- a/Projects/NetStandard/NetStandard.sln +++ b/Projects/NetStandard/NetStandard.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CIAMaster", "CIAMaster\CIAM EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KmsProxy", "KmsProxy\KmsProxy.csproj", "{73824ACB-4FB9-4E11-9A86-E05471B3C979}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeficoMailService", "KeficoMailService\KeficoMailService.csproj", "{63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -33,6 +35,10 @@ Global {73824ACB-4FB9-4E11-9A86-E05471B3C979}.Debug|Any CPU.Build.0 = Debug|Any CPU {73824ACB-4FB9-4E11-9A86-E05471B3C979}.Release|Any CPU.ActiveCfg = Release|Any CPU {73824ACB-4FB9-4E11-9A86-E05471B3C979}.Release|Any CPU.Build.0 = Release|Any CPU + {63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63FF04EE-D1A5-4406-9267-1EE1E9FBB9E7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj b/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj index 10dc7ea..393ed57 100644 --- a/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj +++ b/Projects/NetStandard/PlayGround.NetFramework/PlayGround.NetFramework.csproj @@ -58,6 +58,10 @@ {0bdb3e8c-2f57-4780-8b6f-3ae3f426a6c3} CPMeta + + {63ff04ee-d1a5-4406-9267-1ee1e9fbb9e7} + KeficoMailService + {73824acb-4fb9-4e11-9a86-e05471b3c979} KmsProxy diff --git a/Projects/NetStandard/PlayGround.NetFramework/Program.cs b/Projects/NetStandard/PlayGround.NetFramework/Program.cs index 5accd97..3184846 100644 --- a/Projects/NetStandard/PlayGround.NetFramework/Program.cs +++ b/Projects/NetStandard/PlayGround.NetFramework/Program.cs @@ -1,6 +1,8 @@ using CPMeta.Models; +using KeficoMailService; using Newtonsoft.Json; using System; +using System.Collections.Generic; using System.Threading.Tasks; namespace PlayGround.NetFramework @@ -9,28 +11,52 @@ namespace PlayGround.NetFramework { static void Main(string[] args) { - //global set - string host = "192.168.0.42"; + //html Send + Manager manager = new Manager(); - //random value - string ProductId = "00010032-87a4-45ca-b627-b975d41e35df"; - // string Mac1 = Guid.NewGuid().ToString(); - // string Mac2 = Guid.NewGuid().ToString(); + Address from = new Address { AddressMail = "TraNotify@kefico.co.kr", AddressName = "" }; + List
to = new List
{ new Address { AddressMail = "systemx.kjh@systemx.co.kr", AddressName = "" } }; + List
cc = new List
{ new Address { AddressMail = "systemx.shm@systemx.co.kr", AddressName = "" } }; + List
bcc = new List
{ }; + + string subject = "TRA 테스트용 메일"; + string textSend = manager.SendMailDetail(from, to, cc, bcc, subject, "Tra Notify", MailType.Text); - //Get - Task.Run(async () => - { - var res2 = await CPMeta.CPMeta.HealthCheck(host); - // var res2 = await CPMeta.CPMeta.GetWbmsMetaByProductId(host, ProductId); + // string form = manager.GetFormHtml(new HtmlFormType { FormType="", SystemName="" }); - Console.ForegroundColor = ConsoleColor.DarkBlue; - Console.WriteLine($"Response: {res2} (Trace Guid:)"); - Console.ForegroundColor = ConsoleColor.White; + //form = form.Replace("@HEADTITLE@", "헤드타이틀"); + //form = form.Replace("@TITLE@", "타이틀"); + //form = form.Replace("@BODY@", "내용"); + //form = form.Replace("@URL@", "링크"); + // string htmlSend = manager.SendMailDetail(from, to, cc, bcc, subject, form, MailType.Html); - // var res3 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac1); - // var res4 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac2); - }).Wait(); + + //Text Send + + + // //global set + // string host = "192.168.0.42"; + + // //random value + // string ProductId = "00010032-87a4-45ca-b627-b975d41e35df"; + // // string Mac1 = Guid.NewGuid().ToString(); + //// string Mac2 = Guid.NewGuid().ToString(); + + // //Get + // Task.Run(async () => + // { + // var res2 = await CPMeta.CPMeta.HealthCheck(host); + + // // var res2 = await CPMeta.CPMeta.GetWbmsMetaByProductId(host, ProductId); + + // Console.ForegroundColor = ConsoleColor.DarkBlue; + // Console.WriteLine($"Response: {res2} (Trace Guid:)"); + // Console.ForegroundColor = ConsoleColor.White; + + // // var res3 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac1); + // // var res4 = await CPMeta.CPMeta.GetWbmsMetaByMacAddress(host, Mac2); + // }).Wait(); return; diff --git a/Projects/SystemX.Core/SystemX.Core/Services/HttpService.cs b/Projects/SystemX.Core/SystemX.Core/Services/HttpService.cs index 7aa7cb0..589b1af 100644 --- a/Projects/SystemX.Core/SystemX.Core/Services/HttpService.cs +++ b/Projects/SystemX.Core/SystemX.Core/Services/HttpService.cs @@ -139,7 +139,7 @@ namespace SystemX.Core.Services return response; } - protected HttpClientHandler GetClientHandler() + protected virtual HttpClientHandler GetClientHandler() { HttpClientHandler clientHandler = new HttpClientHandler(); clientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, sslPolicyErrors) => @@ -150,7 +150,7 @@ namespace SystemX.Core.Services return clientHandler; } - protected short SetTimeout(short timeOutSeconds) + protected virtual short SetTimeout(short timeOutSeconds) { short timeoutMin = 5; short timeoutMax = 30; diff --git a/Projects/WebApi/WebApi.Project.ProxyKMS/Models/ProxyKMSConfig.cs b/Projects/WebApi/WebApi.Project.ProxyKMS/Models/ProxyKMSConfig.cs index 6bbe8ac..24bcf6d 100644 --- a/Projects/WebApi/WebApi.Project.ProxyKMS/Models/ProxyKMSConfig.cs +++ b/Projects/WebApi/WebApi.Project.ProxyKMS/Models/ProxyKMSConfig.cs @@ -12,6 +12,10 @@ namespace WebApi.Project.ProxyKMS.Models public string ApiName { get; set; } = string.Empty; public List Functions { get; set; } = new List(); + + public bool CertificateVerify { get; set; } = false; + public string CertPemPath { get; set; } = string.Empty; + public string CertKeyPath { get; set; } = string.Empty; } public class Function diff --git a/Projects/WebApi/WebApi.Project.ProxyKMS/Services/KmsService.cs b/Projects/WebApi/WebApi.Project.ProxyKMS/Services/KmsService.cs index 179fc11..e05e77c 100644 --- a/Projects/WebApi/WebApi.Project.ProxyKMS/Services/KmsService.cs +++ b/Projects/WebApi/WebApi.Project.ProxyKMS/Services/KmsService.cs @@ -1,5 +1,7 @@ using System; +using System.Net.Http; using System.Runtime.CompilerServices; +using System.Security.Cryptography.X509Certificates; using SystemX.Core.DB; using SystemX.Core.Services; using WebApi.Library.Enums; @@ -51,5 +53,95 @@ namespace WebApi.Project.ProxyKMS.Services return response; } + + + public override async Task PostJsonAsync(string url, REQUEST request, short timeOutSeconds = 5) where REQUEST : class where RESPONSE : class + { + RESPONSE response = null; + Guid guid = Guid.NewGuid(); + using (HttpClient httpClient = new HttpClient(GetClientHandler())) + { + try + { + short timeOutSec = SetTimeout(timeOutSeconds); + httpClient.Timeout = new TimeSpan(0, 0, timeOutSec); + httpClient.BaseAddress = new Uri(url ?? ""); + LogXnet.WriteLine($"[POST] Request({guid})::{url}{Environment.NewLine}{request?.ToJson()}", LogXLabel.HTTP); + DateTime requestTime = DateTime.Now; + response = await (await httpClient.PostAsJsonAsync(url, request)).Content.ReadFromJsonAsync(); + LogXnet.WriteLine($"[POST] Rseponse({guid}) ({(DateTime.Now - requestTime).TotalSeconds} sec)::{url}{Environment.NewLine}{response?.ToJson()}", LogXLabel.HTTP); + } + catch (Exception e) + { + LogXnet.WriteLine(e); + LogXnet.WriteLine(e?.InnerException?.InnerException?.Message, LogXLabel.Exception); + } + } + + return response; + } + + public virtual async Task PutJsonAsync(string url, REQUEST request, short timeOutSeconds = 5) where REQUEST : class where RESPONSE : class + { + RESPONSE? response = default(RESPONSE); + Guid guid = Guid.NewGuid(); + + using (HttpClient httpClient = new HttpClient(GetClientHandler())) + { + try + { + var timeOutSec = SetTimeout(timeOutSeconds); + httpClient.Timeout = new TimeSpan(0, 0, timeOutSec); + httpClient.BaseAddress = new Uri($"{url}"); + + LogXnet.WriteLine($"[PUT] Request({guid})::{url}{Environment.NewLine}{request?.ToJson()}", LogXLabel.HTTP); + + DateTime requestTime = DateTime.Now; + var res = await httpClient.PutAsJsonAsync(url, request); + response = await res.Content.ReadFromJsonAsync(); + + LogXnet.WriteLine($"[PUT] Rseponse({guid}) ({(DateTime.Now - requestTime).TotalSeconds} sec)::{url}{Environment.NewLine}{response?.ToJson()}", LogXLabel.HTTP); + } + catch (Exception e) + { + LogXnet.WriteLine(e); + LogXnet.WriteLine(e?.InnerException?.InnerException?.Message, LogXLabel.Exception); + } + } + + return response; + } + + protected override HttpClientHandler GetClientHandler() + { + HttpClientHandler clientHandler = new HttpClientHandler(); + + //인증서가 경로에 있으면 + if (File.Exists(KmsApi.CertPemPath) == true && File.Exists(KmsApi.CertKeyPath) == true) + { + Console.WriteLine($"Cert.Pem Path:{KmsApi.CertPemPath}", LogXLabel.Debug); + Console.WriteLine($"Cert.Key Path:{KmsApi.CertKeyPath}", LogXLabel.Debug); + var cert = X509Certificate2.CreateFromPemFile(KmsApi.CertPemPath, KmsApi.CertKeyPath); + cert = new X509Certificate2(cert.Export(X509ContentType.Pkcs12)); + clientHandler.ClientCertificates.Add(cert); + } + else + { + Console.WriteLine($"File not exist. Cert.Pem Path:{KmsApi.CertPemPath}", LogXLabel.Warning); + Console.WriteLine($"File not exist. Cert.Key Path:{KmsApi.CertKeyPath}", LogXLabel.Warning); + } + + //ssl 인증서 무시 + Console.WriteLine($"CertificateVerify:{KmsApi.CertificateVerify}", LogXLabel.Debug); + if (KmsApi.CertificateVerify == false) + { + clientHandler.ServerCertificateCustomValidationCallback = (message, cert, chain, sslPolicyErrors) => + { + return true; + }; + } + + return clientHandler; + } } }