예제 #1
0
        /// <summary>
        /// 初始化SSL环境
        /// <param name="memory">是否通过内存加载证书</param>
        /// </summary>
        /// <returns></returns>
        public virtual bool Initialize(bool memory = false)
        {
            if (pClient != IntPtr.Zero)
            {
                PemCertFile         = string.IsNullOrWhiteSpace(PemCertFile) ? null : PemCertFile;
                PemKeyFile          = string.IsNullOrWhiteSpace(PemKeyFile) ? null : PemKeyFile;
                KeyPassword         = string.IsNullOrWhiteSpace(KeyPassword) ? null : KeyPassword;
                CAPemCertFileOrPath = string.IsNullOrWhiteSpace(CAPemCertFileOrPath) ? null : CAPemCertFileOrPath;

                return(memory
                    ? SSLSdk.HP_SSLClient_SetupSSLContextByMemory(pClient, VerifyMode, PemCertFile, PemKeyFile, KeyPassword, CAPemCertFileOrPath)
                    : SSLSdk.HP_SSLClient_SetupSSLContext(pClient, VerifyMode, PemCertFile, PemKeyFile, KeyPassword, CAPemCertFileOrPath));
            }

            return(false);
        }