第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

使用 Bouncy-Castle 庫(kù)從證書中讀取 SubjectAlternativeNames

使用 Bouncy-Castle 庫(kù)從證書中讀取 SubjectAlternativeNames

神不在的星期二 2023-05-17 14:31:53
我正在使用bouncy-castle庫(kù)制作一個(gè)TLS-Handshake并Web-Server獲取公共證書。下面是我的代碼 private org.bouncycastle.asn1.x509.Certificate[] certificateList;    public static void main(String... args) {        new BCMain().testBCTLS();    }    private void testBCTLS() {        try {            Socket s = new Socket(InetAddress.getByName(WEB_SERVER), WEB_SERVER_PORT);            //TlsProtocolHandler tlsHandler = new TlsProtocolHandler(s.getInputStream(), s.getOutputStream());            TlsClientProtocol protocol = new TlsClientProtocol(s.getInputStream(), s.getOutputStream(), new SecureRandom());            TlsClient client = new DefaultTlsClient() {                private Boolean connectionStatus = Boolean.FALSE;                @Override                public TlsAuthentication getAuthentication() throws IOException {                    return new ServerOnlyTlsAuthentication() {                        public void notifyServerCertificate(Certificate serverCertificate)                                throws IOException {                            certificateList = serverCertificate.getCertificateList();                        }                    };Subject Alternative Names我想從那個(gè)公共證書中提取JDK 的X509Certificate有提取方法..但我想從證書中獲取相同的方法。SubjectAlternativeNamesbouncy-castle有人可以幫忙嗎?
查看完整描述

1 回答

?
月關(guān)寶盒

TA貢獻(xiàn)1772條經(jīng)驗(yàn) 獲得超5個(gè)贊

我能夠從庫(kù)中提取Subject-Alternative-Names使用X509CertificateHolder和JcaX509CertificateConverter類BouncyCastle..繼續(xù)上面的代碼


import org.bouncycastle.cert.X509CertificateHolder;

import org.bouncycastle.cert.jcajce.JcaX509CertificateConverter;



if (this.certificateList!=null) {

     org.bouncycastle.asn1.x509.Certificate certificate = certificateList[0];

     X509CertificateHolder holder = new X509CertificateHolder(certificate.getEncoded());

     X509Certificate x509Certificate = new JcaX509CertificateConverter().getCertificate(holder);

     Collection<List<?>> sanCollections = x509Certificate.getSubjectAlternativeNames();

}


查看完整回答
反對(duì) 回復(fù) 2023-05-17
  • 1 回答
  • 0 關(guān)注
  • 208 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)