Exemplo n.º 1
0
            public virtual void NotifyServerCertificate(Certificate serverCertificate)
            {
                bool isEmpty = serverCertificate == null || serverCertificate.IsEmpty;

                X509CertificateStructure[] chain = serverCertificate.GetCertificateList();

                // TODO Cache test resources?
                if (isEmpty || !(
                        chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-server-dsa.pem")) ||
                        chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-server-ecdsa.pem")) ||
                        chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-server-rsa-enc.pem")) ||
                        chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-server-rsa-sign.pem"))
                        ))
                {
                    throw new TlsFatalAlert(AlertDescription.bad_certificate);
                }

                if (TlsTestConfig.DEBUG)
                {
                    Console.WriteLine("TLS client received server certificate chain of length " + chain.Length);
                    for (int i = 0; i != chain.Length; i++)
                    {
                        X509CertificateStructure entry = chain[i];
                        // TODO Create fingerprint based on certificate signature algorithm digest
                        Console.WriteLine("    fingerprint:SHA-256 " + TlsTestUtilities.Fingerprint(entry) + " ("
                                          + entry.Subject + ")");
                    }
                }
            }
Exemplo n.º 2
0
        public override void NotifyClientCertificate(Certificate clientCertificate)
        {
            bool isEmpty = (clientCertificate == null || clientCertificate.IsEmpty);

            if (isEmpty != (mConfig.clientAuth == TlsTestConfig.CLIENT_AUTH_NONE))
            {
                throw new InvalidOperationException();
            }
            if (isEmpty && (mConfig.serverCertReq == TlsTestConfig.SERVER_CERT_REQ_MANDATORY))
            {
                throw new TlsFatalAlert(AlertDescription.handshake_failure);
            }

            X509CertificateStructure[] chain = clientCertificate.GetCertificateList();

            // TODO Cache test resources?
            if (!isEmpty && !(chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-client.pem")) ||
                              chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-client-dsa.pem")) ||
                              chain[0].Equals(TlsTestUtilities.LoadCertificateResource("x509-client-ecdsa.pem"))))
            {
                throw new TlsFatalAlert(AlertDescription.bad_certificate);
            }

            if (TlsTestConfig.DEBUG)
            {
                Console.WriteLine("TLS server received client certificate chain of length " + chain.Length);
                for (int i = 0; i != chain.Length; i++)
                {
                    X509CertificateStructure entry = chain[i];
                    // TODO Create fingerprint based on certificate signature algorithm digest
                    Console.WriteLine("    fingerprint:SHA-256 " + TlsTestUtilities.Fingerprint(entry) + " ("
                                      + entry.Subject + ")");
                }
            }
        }
Exemplo n.º 3
0
 public override void NotifyClientCertificate(Certificate clientCertificate)
 {
     X509CertificateStructure[] chain = clientCertificate.GetCertificateList();
     Console.WriteLine("TLS server received client certificate chain of length " + chain.Length);
     for (int i = 0; i != chain.Length; i++)
     {
         X509CertificateStructure entry = chain[i];
         // TODO Create fingerprint based on certificate signature algorithm digest
         Console.WriteLine("    fingerprint:SHA-256 " + TlsTestUtilities.Fingerprint(entry) + " ("
                           + entry.Subject + ")");
     }
 }
Exemplo n.º 4
0
            public override void NotifyServerCertificate(AbstractCertificate serverCertificateIn)
            {
                Certificate serverCertificate = serverCertificateIn as Certificate;

                if (serverCertificate == null)
                {
                    throw new TlsFatalAlert(AlertDescription.bad_certificate);
                }

                X509CertificateStructure[] chain = serverCertificate.GetCertificateList();
                Console.WriteLine("TLS-SRP client received server certificate chain of length " + chain.Length);
                for (int i = 0; i != chain.Length; i++)
                {
                    X509CertificateStructure entry = chain[i];
                    // TODO Create fingerprint based on certificate signature algorithm digest
                    Console.WriteLine("    fingerprint:SHA-256 " + TlsTestUtilities.Fingerprint(entry) + " ("
                                      + entry.Subject + ")");
                }
            }