Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="verifyModel">验证模式</param>
 /// <param name="pemCertFile">证书文件(客户端可选)</param>
 /// <param name="pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLClient(SSLVerifyMode verifyModel, string pemCertFile, string pemKeyFile, string keyPasswod, string caPemCertFileOrPath)
 {
     this.VerifyMode          = verifyModel;
     this.PemCertFile         = pemCertFile;
     this.PemKeyFile          = pemKeyFile;
     this.KeyPasswod          = keyPasswod;
     this.CAPemCertFileOrPath = caPemCertFileOrPath;
 }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="verifyModel">验证模式</param>
 /// <param name="pemCertFile">证书文件</param>
 /// <param name="pemKeyFile">私钥文件</param>
 /// <param name="keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLHttpServer(SSLVerifyMode verifyModel, string pemCertFile, string pemKeyFile, string keyPasswod, string caPemCertFileOrPath, SSLSdk.SNIServerNameCallback sniServerNameCallback)
 {
     this.VerifyMode            = verifyModel;
     this.PemCertFile           = pemCertFile;
     this.PemKeyFile            = pemKeyFile;
     this.KeyPasswod            = keyPasswod;
     this.CAPemCertFileOrPath   = caPemCertFileOrPath;
     this.SNIServerNameCallback = sniServerNameCallback;
 }
Esempio n. 3
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件(客户端可选)</param>
 /// <param name="_pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLClient(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath)
 {
     Interlocked.Increment(ref ObjectReferer);
     this.VerifyMode = _verifyModel;
     this.PemCertFile = _pemCertFile;
     this.PemKeyFile = _pemKeyFile;
     this.KeyPasswod = _keyPasswod;
     this.CAPemCertFileOrPath = _caPemCertFileOrPath;
     Initialize();
 }
Esempio n. 4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件</param>
 /// <param name="_pemKeyFile">私钥文件</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLAgent(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath)
 {
     Interlocked.Increment(ref ObjectReferer);
     this.VerifyMode          = _verifyModel;
     this.PemCertFile         = _pemCertFile;
     this.PemKeyFile          = _pemKeyFile;
     this.KeyPasswod          = _keyPasswod;
     this.CAPemCertFileOrPath = _caPemCertFileOrPath;
     Initialize();
 }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件</param>
 /// <param name="_pemKeyFile">私钥文件</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLHttpServer(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath, SSLSdk.SNIServerNameCallback _sniServerNameCallba)
 {
     Interlocked.Increment(ref ObjectReferer);
     this.VerifyMode            = _verifyModel;
     this.PemCertFile           = _pemCertFile;
     this.PemKeyFile            = _pemKeyFile;
     this.KeyPasswod            = _keyPasswod;
     this.CAPemCertFileOrPath   = _caPemCertFileOrPath;
     this.SNIServerNameCallback = _sniServerNameCallba;
     Initialize();
 }
Esempio n. 6
0
        /// <summary>
        /// 名称:增加 SNI 主机证书(只用于服务端)
        /// 描述:SSL 服务端在 SetupSSLContext() 成功后可以调用本方法增加多个 SNI 主机证书
        /// 返回值:正数		-- 成功,并返回 SNI 主机证书对应的索引,该索引用于在 SNI 回调函数中定位 SNI 主机
        /// 返回值:负数		-- 失败,可通过 SYS_GetLastError() 获取失败原因
        /// </summary>
        /// <param name="verifyMode">SSL 验证模式(参考 EnSSLVerifyMode)</param>
        /// <param name="pemCertFile">证书文件</param>
        /// <param name="pemKeyFile">私钥文件</param>
        /// <param name="keyPassword">私钥密码(没有密码则为空)</param>
        /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证可选)</param>
        /// <returns></returns>
        public int AddServerContext(SSLVerifyMode verifyMode, string pemCertFile, string pemKeyFile, string keyPassword, string caPemCertFileOrPath)
        {
            if (string.IsNullOrWhiteSpace(pemCertFile))
            {
                throw new ArgumentException("参数无效", pemCertFile);
            }
            if (string.IsNullOrWhiteSpace(pemKeyFile))
            {
                throw new ArgumentException("参数无效", pemKeyFile);
            }
            keyPassword         = string.IsNullOrWhiteSpace(keyPassword) ? null : keyPassword;
            caPemCertFileOrPath = string.IsNullOrWhiteSpace(caPemCertFileOrPath) ? null : caPemCertFileOrPath;

            return(SSLSdk.HP_SSLServer_AddSSLContext(pServer, verifyMode, pemCertFile, pemKeyFile, KeyPassword, caPemCertFileOrPath));
        }
Esempio n. 7
0
        /// <summary>
        /// 名称:增加 SNI 主机证书(只用于服务端)
        /// 描述:SSL 服务端在 SetupSSLContext() 成功后可以调用本方法增加多个 SNI 主机证书
        /// 返回值:正数		-- 成功,并返回 SNI 主机证书对应的索引,该索引用于在 SNI 回调函数中定位 SNI 主机
        /// 返回值:负数		-- 失败,可通过 SYS_GetLastError() 获取失败原因
        /// </summary>
        /// <param name="verifyMode">SSL 验证模式(参考 EnSSLVerifyMode)</param>
        /// <param name="pemCertFile">证书文件</param>
        /// <param name="pemKeyFile">私钥文件</param>
        /// <param name="keyPasswod">私钥密码(没有密码则为空)</param>
        /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证可选)</param>
        /// <returns></returns>
        public int AddServerContext(SSLVerifyMode verifyMode, string pemCertFile, string pemKeyFile, string keyPasswod, string caPemCertFileOrPath)
        {
            /*if (SSLSdk.HP_SSL_IsValid() == false)
             * {
             *  throw new InvalidOperationException("请先调用Initialize()方法初始化SSL环境");
             * }*/

            if (string.IsNullOrWhiteSpace(pemCertFile))
            {
                throw new ArgumentException("参数无效", pemCertFile);
            }
            if (string.IsNullOrWhiteSpace(pemKeyFile))
            {
                throw new ArgumentException("参数无效", pemKeyFile);
            }
            keyPasswod          = string.IsNullOrWhiteSpace(keyPasswod) ? null : keyPasswod;
            caPemCertFileOrPath = string.IsNullOrWhiteSpace(caPemCertFileOrPath) ? null : caPemCertFileOrPath;

            return(SSLSdk.HP_SSLServer_AddSSLContext(pServer, verifyMode, pemCertFile, pemKeyFile, KeyPasswod, caPemCertFileOrPath));
        }
Esempio n. 8
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件(客户端可选)</param>
 /// <param name="_pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLPullServer(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath, SSLSdk.SNIServerNameCallback _sniServerNameCallba)
     : base(_verifyModel, _pemCertFile, _pemKeyFile, _keyPasswod, _caPemCertFileOrPath, _sniServerNameCallba)
 {
 }
Esempio n. 9
0
 public static extern bool HP_SSL_Initialize(SSLSessionMode sessionMode, SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod, string lpszCAPemCertFileOrPath);
Esempio n. 10
0
 /// <summary>
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件(客户端可选)</param>
 /// <param name="_pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLPullAgent(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath)
     : base(_verifyModel, _pemCertFile, _pemKeyFile, _keyPasswod, _caPemCertFileOrPath)
 {
 }
Esempio n. 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="verifyModel">验证模式</param>
 /// <param name="pemCertFile">证书文件(客户端可选)</param>
 /// <param name="pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLPackAgent(SSLVerifyMode verifyModel, string pemCertFile, string pemKeyFile, string keyPasswod, string caPemCertFileOrPath)
     : base(verifyModel, pemCertFile, pemKeyFile, keyPasswod, caPemCertFileOrPath)
 {
 }
Esempio n. 12
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="verifyModel">验证模式</param>
 /// <param name="pemCertFile">证书文件(客户端可选)</param>
 /// <param name="pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 /// <param name="sniServerNameCallback">SNI 回调函数指针(可选)</param>
 public SSLPackServer(SSLVerifyMode verifyModel, string pemCertFile, string pemKeyFile, string keyPasswod, string caPemCertFileOrPath, SSLSdk.SNIServerNameCallback sniServerNameCallback)
     : base(verifyModel, pemCertFile, pemKeyFile, keyPasswod, caPemCertFileOrPath, sniServerNameCallback)
 {
 }
Esempio n. 13
0
 public static extern bool HP_SSLServer_SetupSSLContextByMemory(IntPtr pServer, SSLVerifyMode verifyMode /* SSL_VM_NONE */, string lpszPemCert /* nullptr */, string lpszPemKey /* nullptr */, string lpszKeyPassword /* nullptr */, string lpszCAPemCert /* nullptr */, SNIServerNameCallback fnServerNameCallback /* nullptr */);
Esempio n. 14
0
 public static extern bool HP_SSLServer_SetupSSLContext(IntPtr pServer, SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod, string lpszCAPemCertFileOrPath, SNIServerNameCallback fnServerNameCallback);
Esempio n. 15
0
 public static extern int HP_SSLServer_AddSSLContext(IntPtr pServer, SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod, string lpszCAPemCertFileOrPath);
Esempio n. 16
0
 public static extern int HP_SSLServer_AddSSLContextByMemory(IntPtr pServer, SSLVerifyMode verifyMode, string lpszPemCert, string lpszPemKey, string lpszKeyPassword /* nullptr */, string lpszCAPemCert /* nullptr */);
Esempio n. 17
0
 public static extern bool HP_SSLClient_SetupSSLContext(IntPtr pClient, SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod, string lpszCAPemCertFileOrPath);
Esempio n. 18
0
 public static extern bool HP_SSLClient_SetupSSLContextByMemory(IntPtr pClient, SSLVerifyMode verifyMode /* SSL_VM_NONE */, string lpszPemCert /* nullptr */, string lpszPemKey /* nullptr */, string lpszKeyPassword /* nullptr */, string lpszCAPemCert /* nullptr */);
Esempio n. 19
0
 /// <summary>
 /// 增加 SNI 主机证书(通过内存加载证书)
 /// 描述:SSL 服务端在 SetupSSLContext() 成功后可以调用本方法增加多个 SNI 主机证书
 /// 返回值:正数		-- 成功,并返回 SNI 主机证书对应的索引,该索引用于在 SNI 回调函数中定位 SNI 主机
 /// 返回值:负数		-- 失败,可通过 SYS_GetLastError() 获取失败原因
 /// </summary>
 /// <param name="verifyMode">SSL 验证模式(参考 EnSSLVerifyMode)</param>
 /// <param name="pemCert">证书内容</param>
 /// <param name="pemKey">私钥内容</param>
 /// <param name="keyPassword">私钥密码(没有密码则为空)</param>
 /// <param name="caPemCert">CA 证书内容(单向验证可选)</param>
 /// <returns></returns>
 public int AddSSLContextByMemory(SSLVerifyMode verifyMode, string pemCert, string pemKey, string keyPassword = null, string caPemCert = null)
 {
     return(SSLSdk.HP_SSLServer_AddSSLContextByMemory(pServer, verifyMode, pemCert, pemKey, keyPassword, caPemCert));
 }
Esempio n. 20
0
 public static extern int HP_SSL_AddServerContext(SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod /* nullptr */, string lpszCAPemCertFileOrPath /* nullptr */);
Esempio n. 21
0
 public static extern bool HP_SSL_Initialize(SSLSessionMode sessionMode, SSLVerifyMode verifyMode, string lpszPemCertFile, string lpszPemKeyFile, string lpszKeyPasswod, string lpszCAPemCertFileOrPath, SSLSdk.SNIServerNameCallback fnServerNameCallback);
Esempio n. 22
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="_verifyModel">验证模式</param>
 /// <param name="_pemCertFile">证书文件(客户端可选)</param>
 /// <param name="_pemKeyFile">私钥文件(客户端可选)</param>
 /// <param name="_keyPasswod">私钥密码(没有密码则为空)</param>
 /// <param name="_caPemCertFileOrPath">CA 证书文件或目录(单向验证或客户端可选)</param>
 public SSLPullClient(SSLVerifyMode _verifyModel, string _pemCertFile, string _pemKeyFile, string _keyPasswod, string _caPemCertFileOrPath)
     : base(_verifyModel, _pemCertFile, _pemKeyFile, _keyPasswod, _caPemCertFileOrPath)
 {
 }