Example #1
0
        /// <summary>
        /// 初始化SSL环境
        /// </summary>
        /// <returns></returns>
        protected virtual bool Initialize()
        {
            lock (SSLInitLock)
            {
                if (SSLSdk.HP_SSL_IsValid() == false)
                {
                    if (string.IsNullOrWhiteSpace(PemCertFile))
                    {
                        throw new NullReferenceException("PemCertFile");
                    }

                    if (string.IsNullOrWhiteSpace(PemKeyFile))
                    {
                        throw new NullReferenceException("PemKeyFile");
                    }

                    if (string.IsNullOrWhiteSpace(KeyPasswod))
                    {
                        throw new NullReferenceException("KeyPasswod");
                    }

                    if (string.IsNullOrWhiteSpace(CAPemCertFileOrPath))
                    {
                        throw new NullReferenceException("CAPemCertFileOrPath");
                    }

                    return(SSLSdk.HP_SSL_Initialize(SSLSessionMode.Server, VerifyMode, PemCertFile, PemKeyFile, KeyPasswod, CAPemCertFileOrPath));
                }

                return(true);
            }
        }
Example #2
0
        /// <summary>
        /// 初始化SSL环境
        /// </summary>
        /// <returns></returns>
        protected virtual bool Initialize()
        {
            lock (SSLInitLock)
            {
                if (SSLSdk.HP_SSL_IsValid() == false)
                {
                    PemCertFile         = string.IsNullOrWhiteSpace(PemCertFile) ? null : PemCertFile;
                    PemKeyFile          = string.IsNullOrWhiteSpace(PemKeyFile) ? null : PemKeyFile;
                    KeyPasswod          = string.IsNullOrWhiteSpace(KeyPasswod) ? null : KeyPasswod;
                    CAPemCertFileOrPath = string.IsNullOrWhiteSpace(CAPemCertFileOrPath) ? null : CAPemCertFileOrPath;

                    return(SSLSdk.HP_SSL_Initialize(SSLSessionMode.Client, VerifyMode, PemCertFile, PemKeyFile, KeyPasswod, CAPemCertFileOrPath, null));
                }

                return(true);
            }
        }
Example #3
0
        /// <summary>
        /// 初始化SSL环境
        /// </summary>
        /// <param name="callback"></param>
        /// <returns></returns>
        public virtual bool Initialize()
        {
            lock (SSLInitLock)
            {
                if (SSLSdk.HP_SSL_IsValid() == false)
                {
                    PemCertFile         = string.IsNullOrWhiteSpace(PemCertFile) ? null : PemCertFile;
                    PemKeyFile          = string.IsNullOrWhiteSpace(PemKeyFile) ? null : PemKeyFile;
                    KeyPasswod          = string.IsNullOrWhiteSpace(KeyPasswod) ? null : KeyPasswod;
                    CAPemCertFileOrPath = string.IsNullOrWhiteSpace(CAPemCertFileOrPath) ? null : CAPemCertFileOrPath;

                    return(SSLSdk.HP_SSL_Initialize(SSLSessionMode.Server, VerifyMode, PemCertFile, PemKeyFile, KeyPasswod, CAPemCertFileOrPath, SNIServerNameCallback));
                }

                return(true);
            }
        }