// Get subject key identifier from certificate
byte[] skid = XMLX509SKI.getSKIBytesFromCert(cert);
// Use X509CertSelector to match on certificate using the skid,
// thereby testing that the returned skid was correct
X509CertSelector xcs = new X509CertSelector();
// DER-encode skid - required by X509CertSelector
byte[] encodedSkid = new byte[skid.length+2];
encodedSkid[0] = 0x04; // OCTET STRING tag value
encodedSkid[1] = (byte) skid.length; // length
System.arraycopy(skid, 0, encodedSkid, 2, skid.length);
xcs.setSubjectKeyIdentifier(encodedSkid);
CertStore cs = CertStore.getInstance(
"Collection",
new CollectionCertStoreParameters(Collections.singleton(cert)));