private static void registerCert(X509Certificate cert, int type, String id, Signature sig) throws DigiDocException { String sid = id; if (sid != null) sid = sid.replace(" ", "_"); CertValue cval = new CertValue(sid, cert, type, sig); sig.addCertValue(cval); CertID cid = new CertID(sig, cert, type); sig.addCertID(cid); if (type != CertID.CERTID_TYPE_SIGNER) cid.setUri("#" + cval.getId()); }