Пример #1
0
        private void SetupSSLCertificates()
        {
            hMailServer.SSLCertificate cert = _application.Settings.SSLCertificates.Add();
            cert.CertificateFile = "file1.txt";
            cert.Name            = "name1";
            cert.PrivateKeyFile  = "pk1";
            cert.Save();

            cert = _application.Settings.SSLCertificates.Add();
            cert.CertificateFile = "file2.txt";
            cert.Name            = "name2";
            cert.PrivateKeyFile  = "pk2";
            cert.Save();
        }
Пример #2
0
        public void SetupSSLCertificateWithPassword()
        {
            string originalPath = Environment.CurrentDirectory;

            Environment.CurrentDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\SSL examples\\WithPassword";
            string sslPath = Environment.CurrentDirectory;

            Environment.CurrentDirectory = originalPath;

            hMailServer.SSLCertificate sslCertificate = _application.Settings.SSLCertificates.Add();
            sslCertificate.Name            = "Example";
            sslCertificate.CertificateFile = sslPath + "\\server.crt";
            sslCertificate.PrivateKeyFile  = sslPath + "\\server.key";
            sslCertificate.Save();

            hMailServer.TCPIPPort port = _application.Settings.TCPIPPorts.Add();
            port.Address          = "0.0.0.0";
            port.PortNumber       = 251;
            port.UseSSL           = true;
            port.SSLCertificateID = sslCertificate.ID;
            port.Protocol         = hMailServer.eSessionType.eSTSMTP;
            port.Save();

            _application.Stop();
            _application.Start();

            Utilities.AssertReportedError();
        }
Пример #3
0
        private hMailServer.SSLCertificate SetupSSLCertificate()
        {
            string originalPath = Environment.CurrentDirectory;

            Environment.CurrentDirectory = Environment.CurrentDirectory + "\\..\\..\\..\\SSL examples";
            string sslPath = Environment.CurrentDirectory;

            Environment.CurrentDirectory = originalPath;

            hMailServer.SSLCertificate sslCertificate = _application.Settings.SSLCertificates.Add();
            sslCertificate.Name            = "Example";
            sslCertificate.CertificateFile = sslPath + "\\example.crt";
            sslCertificate.PrivateKeyFile  = sslPath + "\\example.key";
            sslCertificate.Save();

            return(sslCertificate);
        }
Пример #4
0
        public void TestSSLCertificate()
        {
            hMailServer.Settings oSettings = SingletonProvider <Utilities> .Instance.GetApp().Settings;

            hMailServer.SSLCertificate sslcert = oSettings.SSLCertificates.Add();

            sslcert.CertificateFile = "somefile.dat";
            sslcert.PrivateKeyFile  = "someprivatefile.dat";
            sslcert.Save();

            if (sslcert.ID == 0)
            {
                throw new Exception("SSL certificate not saved properly");
            }

            oSettings.SSLCertificates.DeleteByDBID(sslcert.ID);
        }