Exemplo n.º 1
0
        /// <summary>
        /// Gets the public key from a certificate in Base64 PEM format.
        /// </summary>
        /// <returns>Base64 encoded public key.</returns>
        public string GetPublicKey()
        {
            var sb = new StringBuilder();

            sb.AppendLine("-----BEGIN CERTIFICATE-----");
            sb.AppendLine(ConvertEx.ToBase64String(_certificate.Export(X509ContentType.Cert), 64));
            sb.Append("-----END CERTIFICATE-----");

            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the decrypted private key from a certificate in Base64 PEM format.
        /// </summary>
        /// <returns>Base64 encoded private key that has been decrypted.</returns>
        public string GetPrivateKey()
        {
            var sb = new StringBuilder();

            sb.AppendLine("-----BEGIN RSA PRIVATE KEY-----");
            sb.AppendLine(ConvertEx.ToBase64String(_certificate.ExportPrivateKey(), 64));
            sb.Append("-----END RSA PRIVATE KEY-----");

            return(sb.ToString());
        }
Exemplo n.º 3
0
        protected bool IsValidSecurityResponse(string responseSecKey)
        {
            // build expected secKey
            byte[] tempbytes      = Encoding.UTF8.GetBytes(string.Concat(this.securityKey, WSConst.HeaderSecurityGUID));
            string expectedSecKey = ConvertEx.ToBase64String(CryptoUtils.ComputeSha1Hash(tempbytes));

            Logger.WriteDebug(this.loggerID, "Expected sec key: " + expectedSecKey);
            Logger.WriteDebug(this.loggerID, "Response sec key: " + responseSecKey);

            if (expectedSecKey == responseSecKey)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
 protected string GetSecurityKey()
 {
     byte[] secBytes = CryptoUtils.GetRandomBytes(16);
     return(ConvertEx.ToBase64String(secBytes));
 }