できましたー。
一部ですが、こんな感じです。
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
・・・
URLConnection ucon = url.openConnection();
ucon.setRequestProperty("Content-type", "application/octet-stream");
ucon.connect();
HttpsURLConnection ucons = (HttpsURLConnection)ucon;
PublicKey key = getPublicKey();
for(Certificate c : ucons.getServerCertificates()){
c.verify(key);
}
・・・
}
private PublicKey getPublicKey() throws CertificateException,FileNotFoundException{
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate c = cf.generateCertificate(this.getClass().getResourceAsStream("test.cert2"));
return c.getPublicKey();
}
お教えいただきありがとうございました。
とても助かりました。