Groovy web console

subscribe to the feed Subscribe
to this
site

arfg

Published 1 month ago by arfg with tags arfg
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts

import java.security.cert.CertificateFactory
import sun.security.x509.X509CertImpl
import java.security.PublicKey

String b64="MIIDdzCCAl+gAwIBAgIERVdMADANBgkqhkiG9w0BAQsFADBsMQswCQYDVQQGEwJERTEPMA0GA1UECBMGQmVybGluMQ8wDQYDVQQHEwZCZXJsaW4xDDAKBgNVBAoTA0RldjEMMAoGA1UECxMDRGV2MR8wHQYDVQQDExZodHRwczovLzE5Mi4xNjguMTM3LjI1MB4XDTE5MDMwMTE5MTcwMloXDTE5MDUzMDE5MTcwMlowbDELMAkGA1UEBhMCREUxDzANBgNVBAgTBkJlcmxpbjEPMA0GA1UEBxMGQmVybGluMQwwCgYDVQQKEwNEZXYxDDAKBgNVBAsTA0RldjEfMB0GA1UEAxMWaHR0cHM6Ly8xOTIuMTY4LjEzNy4yNTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJSXF//DGsQC3anVt4UEvofTtaMRtcGKRwktKrZqE1PuUQzqiYJPDC/wNTBVSMmSS3xcx27YTgFW8RVHpPbQdf+8RHMr7EX7mhBVM8raKg7PeCWbdAy8ZYObAyho7bWlgdbP68XpX3GHAGmrMyQpPqEaMZj1r2v8OAkJV6h7NsLVGBWbaBKfdimKn9Y1DmQmG8lE/t/ToPyKpwQNSGr0o9L2hgDVqR638PQpCVZ4S0EMOZiferay3K0b9Q7SMdAh6NsMEzITK5aCC5CJPy2RvhuCE26AhLvCAABWaotYj3YcN6jgKnrBjo0RHaSXaAsl6VmIgEgFbUT1d/RE+QmKIkUCAwEAAaMhMB8wHQYDVR0OBBYEFDbY19/AJzZuEPZ0DngBa6/wR266MA0GCSqGSIb3DQEBCwUAA4IBAQAxhrIX8GDQSTnH9WAYm04Vk/GhJl19BXeB5mGgVr1SyyKjQvyZ+BHx2AUaweNH5Fl41gNfzgFjd2E1TAk8FrHtlDS0Vo9v66FY/Hbcmv64n2EYVmscc7YAm9ri5uyGWUyHZQnoRLnCh9BOzn8oK1MsK9jV0etggjZLMswMAglGvqVlHocXOY/F3U+ejopU2EK4S/xOVlswCBJKH16ass5p0mIhMOxcuh3XX0ZkVcV4+EkrGhIvuz9fI2i+K5v9Mqz6tseTEc+q+2yqpqX1GjXkNKDBfZMfx9d3fAGAKL/PwU16jrlOm4nhJvDFV1CPB7ZacPTWCTc8uuNlwLtPuhhg"
byte[] decoded = b64.decodeBase64()
CertificateFactory fact = CertificateFactory.getInstance("X.509"); 
ByteArrayInputStream bis = new ByteArrayInputStream (decoded); 
X509CertImpl cert = (X509CertImpl)fact.generateCertificate(bis); 
// see http://www.docjar.com/docs/api/sun/security/x509/X509CertImpl.html
System.out.println(cert.getSerialNumber());
System.out.println(cert.getIssuerDN());
System.out.println(cert.getSubjectDN());