/// <summary> /// 初始化SSL环境 /// </summary> /// <param name="memory">是否通过内存加载证书</param> /// <returns></returns> protected virtual bool Initialize(bool memory = false) { lock (SSLInitLock) { //if (SSLSdk.HP_SSL_IsValid() == false) { PemCertFile = string.IsNullOrWhiteSpace(PemCertFile) ? null : PemCertFile; PemKeyFile = string.IsNullOrWhiteSpace(PemKeyFile) ? null : PemKeyFile; KeyPassword = string.IsNullOrWhiteSpace(KeyPassword) ? null : KeyPassword; CAPemCertFileOrPath = string.IsNullOrWhiteSpace(CAPemCertFileOrPath) ? null : CAPemCertFileOrPath; var ret = memory ? SSLSdk.HP_SSLAgent_SetupSSLContextByMemory(pAgent, VerifyMode, PemCertFile, PemKeyFile, KeyPassword, CAPemCertFileOrPath) : SSLSdk.HP_SSLAgent_SetupSSLContext(pAgent, VerifyMode, PemCertFile, PemKeyFile, KeyPassword, CAPemCertFileOrPath); System.Diagnostics.Trace.WriteLine($"ssl Initialize : {ret}"); } return(true); } }