Exemple #1
0
        /// <summary>5.3.7	PKCS#1签名验证
        ///
        /// </summary>
        /// <param name="sSource"></param>
        /// <param name="bSignData"></param>
        /// <param name="sX509Certificate"></param>
        /// <returns></returns>
        public static Boolean verifyPKCS1(String sSource, String bSignData, String sX509Certificate)
        {
            SecuInter.X509Certificate oCert = new SecuInter.X509Certificate();
            oCert.Decode(sX509Certificate);

            Boolean isOK = false;

            if (oCert == null)
            {
                throw new Exception("未选择证书!");
            }
            SecuInter.signature oSignature = new SecuInter.signature();
            SecuInter.Utilities oUtil      = new SecuInter.Utilities();

            oSignature.Certificate = oCert;
            oSignature.Algorithm   = SECUINTER_SIGNATURE_ALGORITHM.SECUINTER_SHA1WithRSA_ALGORITHM;
            byte[] bContent = Encoding.Default.GetBytes(sSource);
            if (oSignature.Verify(bContent, oUtil.Base64Decode(bSignData)))
            {
                isOK = true;
            }
            else
            {
                throw new Exception("验证不通过!");
            }

            oSignature = null;
            oUtil      = null;

            return(isOK);
        }
Exemple #2
0
 /// <summary>5.2.7	从HTTPS通信中获取证书对象(SSL用)
 /// HttpClientCertificate hCert = Request.ClientCertificate;
 /// byte[] bCert=hCert.Certificate;
 /// </summary>
 /// <param name="hCert"></param>
 /// <returns></returns>
 public static SecuInter.X509Certificate getX509Certificate(byte[] bCert)
 {
     SecuInter.X509Certificate oCert = new SecuInter.X509Certificate();
     try
     {
         oCert.Decode(bCert);
         return(oCert);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Exemple #3
0
 /// <summary>5.2.3 根据证书字符串获取证书
 ///
 /// </summary>
 /// <param name="sX509Certificate"></param>
 /// <returns></returns>
 public static SecuInter.X509Certificate getX509Certificate(string sX509Certificate)
 {
     SecuInter.X509Certificate oX509Certificate = new SecuInter.X509Certificate();
     oX509Certificate.Decode(sX509Certificate);
     return(oX509Certificate);
 }