PublicKeyStub pk1 = new PublicKeyStub("kkk", "fff", new byte[]{1,2,3,4,5});
i.setPublicKey(pk1);
// try with the same key
CertificateStub c1 = new CertificateStub("fff", null, null, pk1);
i.addCertificate(c1);
assertSame(c1, i.certificates()[0]);
// try Certificate with different key
try {
i.addCertificate(new CertificateStub("ccc", null, null, new PublicKeyStub("k2", "fff", new byte[]{6,7,8,9,0})));
fail("KeyManagementException should be thrown");
} catch (KeyManagementException ok) {}