有没有办法在Golang中从X509Certificate中提取CN?
之前我们在Java中做了类似于这样的操作。
之前我们在Java中做了类似于这样的操作。
private String getCNFromCertificate() throws InvalidNameException, CertificateException, IOException {
X509Certificate certificate = getCert(DeploymentConfiguration.getPemCertPath().get());
String commonName = new LdapName(certificate.getSubjectX500Principal().getName()).getRdns().stream()
.filter(i -> i.getType().equalsIgnoreCase("CN")).findFirst().get().getValue().toString();
return commonName;
}
有哪些Golang的包可以执行类似的任务呢?或者说,从Golang证书中提取CN有什么更好的选择呢?
先行致谢。