Пример #1
0
        private static void ObtainLatestBankCertificates()
        {
            /*
             * This obtains the latest certificates used by the bank.
             * They have a finite lifecycle, so they must be renewed a regular interval
             *  - Root certifiate: 10 years
             *  - Signing certificate: 2 years
             *  - Encryption certificate: 2 years
             */
            Console.WriteLine("Requesting bank certificates ...");

            // Obtain bank certificate
            var res = PKIClient.GetBankCertificate();

            if (!CheckForError(res))
            {
                exitProgram(Int32.Parse(res.Error.ReturnCode));
                return;
            }

            Console.WriteLine("  Retrieved new certificates from bank.");
            Console.WriteLine("Saving bank certificates ...");

            // Save the bank certificates
            CertStore.SetCertificate(CertStore.Certificiates.BankRoot, res.Response.GetBankCertificateResponse.BankRootCert);
            CertStore.SetCertificate(CertStore.Certificiates.BankEncryption, res.Response.GetBankCertificateResponse.BankEncryptionCert);
            CertStore.SetCertificate(CertStore.Certificiates.BankSigning, res.Response.GetBankCertificateResponse.BankSigningCert);
            Console.WriteLine(" Bank certificates successfully saved.");

            // Instruct the PKIClient to use the new certificates
            PKIClient.BankRootCertificate = CertStore.GetCertificate(CertStore.Certificiates.BankRoot);
            PKIClient.SetBankCertificates(CertStore.GetCertificate(CertStore.Certificiates.BankEncryption), CertStore.GetCertificate(CertStore.Certificiates.BankSigning));
            Console.WriteLine(" Using new bank certificates.");
        }
Пример #2
0
        private static WrappedResponse <GetBankCertificateOutType> ObtainLatestBankCertificates(PKIClient client)
        {
            var res = client.GetBankCertificate();

            if (!CheckForError(res))
            {
                return(null);
            }

            return(res);
        }