public bool IsCertificateTrusted(X509Certificate channelCertificate, CertificateProof proof)
        {
            var cert = new EphemeralCertificate(proof.EphemeralCertificate);

            if (!(cert.ValidFrom <= DateTime.UtcNow && DateTime.UtcNow <= cert.ValidTo))
            {
                return(false);
            }

            if (!channelCertificate.GetRawCertData().SequenceEqual(cert.ClientCertificate))
            {
                return(false);
            }

            lock (m_syncRoot)
            {
TryAgain:
                if (!m_list.TryGetValue(HexToString(cert.TrustedCertThumbprint), out var data))
                {
                    if (m_lastCertRefresh.ElapsedSeconds() > 60)//check at most once per minute
                    {
                        RebuildCerts();
                        goto TryAgain;
                    }

                    return(false);
                }
                return(cert.ValidateSignature(new X509Certificate2(data)));
            }
        }
Esempio n. 2
0
        private void createSaveProofButon_Click(object sender, EventArgs e)
        {
            if (DecryptPrivateKeyDialog.TryDecryptIfNessecary(this.certificate, "Sign Certificate Proof"))
              {
            var proof = new CertificateProof(this.createProofTextTextBox.Text);
            var signedProof = new Signed<CertificateProof>(proof, this.certificate);

            SaveFileDialog dialog = new SaveFileDialog();
            dialog.Filter = ProofFileFilter;
            dialog.Title = "Save Certificate Proof";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
              signedProof.Save(dialog.FileName);
            }
              }
        }
Esempio n. 3
0
        public bool IsCertificateTrusted(CtpNetStream stream, CertificateProof proof)
        {
            var eph = new EphemeralCertificate(proof.EphemeralCertificate);

            if (!TryFindCertificate(HexToString(eph.TrustedCertThumbprint), out var signingCert, out var account))
            {
                return(false);
            }

            if (!eph.ValidateSignature(signingCert))
            {
                return(false);
            }

            if (!account.IsIPAllowed(stream.RemoteEndpoint.Address))
            {
                return(false);
            }

            GrantPermissions(stream, account, eph.LoginName, eph.GrantedRoles, eph.DeniedRoles);

            return(true);
        }
 public bool IsCertificateTrusted(X509Certificate channelCertificate, CertificateProof proof)
 {
     return(m_trustedRemotes.IsCertificateTrusted(channelCertificate, proof));
 }
Esempio n. 5
0
 public bool IsCertificateTrusted(X509Certificate channelCertificate, CertificateProof proof)
 {
     throw new NotImplementedException();
 }