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

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Bouncy-Castle 庫從證書中讀取 SubjectAlternativeNames

使用 Bouncy-Castle 庫從證書中讀取 SubjectAlternativeNames

神不在的星期二 2023-05-17 14:31:53
我正在使用bouncy-castle庫制作一個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我想從那個公共證書中提取JDK 的X509Certificate有提取方法..但我想從證書中獲取相同的方法。SubjectAlternativeNamesbouncy-castle有人可以幫忙嗎?
查看完整描述

1 回答

?
月關(guān)寶盒

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

我能夠從庫中提取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();

}


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

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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