package api;

/**
 * @author zyh
 * @since 2024/12/19
 */

import com.sunyard.chsm.utils.CertUtil;

import org.bouncycastle.asn1.x509.Extensions;
import org.bouncycastle.asn1.x509.KeyUsage;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.cert.jcajce.JcaX509CertificateHolder;
import org.junit.jupiter.api.Test;

import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateParsingException;
import java.security.cert.X509Certificate;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TestCert {


    @Test
    public void test1() throws CertificateParsingException, CertificateEncodingException {
        String cert = "-----BEGIN CERTIFICATE-----\n" +
                "MIIE+DCCA+CgAwIBAgIQXQbkqDIONNM6NOW9uz38tDANBgkqhkiG9w0BAQsFADAz\n" +
                "MQswCQYDVQQGEwJDTjERMA8GA1UECgwIVW5pVHJ1c3QxETAPBgNVBAMMCFNIRUNB\n" +
                "IEcyMB4XDTIwMTAxMzA3NTgxM1oXDTIzMTAxMzE1NTk1OVowgdQxOTA3BgNVBAMM\n" +
                "MOa1i+ivleW5v+WPkemTtuihjOiCoeS7veaciemZkOWFrOWPuOS4iua1t+WIhuih\n" +
                "jDEzMDEGA1UECwwq5bm/5Y+R6ZO26KGM6IKh5Lu95pyJ6ZmQ5YWs5Y+45LiK5rW3\n" +
                "5YiG6KGMMTMwMQYDVQQKDCrlub/lj5Hpk7booYzogqHku73mnInpmZDlhazlj7jk\n" +
                "uIrmtbfliIbooYwxDzANBgNVBAcMBuS4iua1tzEPMA0GA1UECAwG5LiK5rW3MQsw\n" +
                "CQYDVQQGEwJDTjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALRgbK63\n" +
                "ZyrEmDkxgiwBZXjFp5KQAsqMKBGzORKDQ88I+hW6nKLMglbWTyfd26pPWoSy3TFs\n" +
                "JN1HrBHkyfcKoYQ8KKN4bnH7hRrXV2LBBIPZdM6Tq3IHnTLg9KszCi1+Do/A7HQz\n" +
                "yr9Rz0RyUkm7KnCt7dfGQKMfPGBGdabMY3HUs/kwGwVQG9KqyEu+wUGXP6nuty8A\n" +
                "uI9u2OcUjPpfHcrH3gXwsFeiUUBt0/gEQX1UcTLaUYMcW67p5DQxi/pA3BGtbWvj\n" +
                "yiAzIRyYcQgJpg0Ve0bI8nGqbdb1JDR3Spz1B90YOIIQ89oKfOLlkS3TUlJaTY2Q\n" +
                "guQ8CrY4zMYsfI0CAwEAAaOCAWQwggFgMB8GA1UdIwQYMBaAFFaI3uMYQ4K3cqQm\n" +
                "60SpYtCHxKwmMB0GA1UdDgQWBBRaOJdZxE5Q26SKcgRiQWdqkb8xlzAOBgNVHQ8B\n" +
                "Af8EBAMCBsAwFAYDVR0lBA0wCwYJKoZIhvcvAQEFMCIGA1UdIAQbMBkwCgYIKoEc\n" +
                "hu86AQMwCwYJKoEchu86AQIEMAwGA1UdEwEB/wQCMAAwfQYIKwYBBQUHAQEEcTBv\n" +
                "MDgGCCsGAQUFBzABhixodHRwOi8vb2NzcDMuc2hlY2EuY29tL29jc3Avc2hlY2Ev\n" +
                "c2hlY2Eub2NzcDAzBggrBgEFBQcwAoYnaHR0cDovL2xkYXAyLnNoZWNhLmNvbS9y\n" +
                "b290L3NoZWNhZzIuZGVyMEcGA1UdHwRAMD4wPKA6oDiGNmh0dHA6Ly9sZGFwMi5z\n" +
                "aGVjYS5jb20vQ0EyMDAxMS9SQTEyMDUwMTAwL0NSTDYzOTMyLmNybDANBgkqhkiG\n" +
                "9w0BAQsFAAOCAQEAszG0ZWsZIylM3sPUKh1et2PIZtJ5jU4P4s8AwZAZEwuUpfay\n" +
                "C6gJvfSqY4i6XQ+w2RVGKZFfq0oq23Sxv+jzzhuvL0bOyOzaVzS0pZwhBZ0ggfd7\n" +
                "DY8irQ6CbKKp/ngE0vDILi00N/BujfFRQlg5Whr5i81wSBqXwry+EcVUa5t06ns/\n" +
                "x545wQBnHNGrMtAaACFtjQiXdBfI02sEEd8uzdgMQn6FLxXuHFHbUF4VAue1TL5f\n" +
                "UPNsAHFkqrdDDP5Ou7Dk2dE/5bti53wH1qQMbtTsdVp91Z9hzVAlw+WR3Ton7G1W\n" +
                "S01olvhEUw9Bj7GhohZjFpzwcwwo7AQxA2aGFA==\n" +
                "-----END CERTIFICATE-----\n";

        X509Certificate x509Certificate = CertUtil.convertToX509Cert(cert);




        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        Date dt = new Date();
        String startTime = sdf.format(dt);
        System.out.println(startTime);




    }
}