Validate BIMI certificates

This commit is contained in:
M66B
2021-07-14 17:42:22 +02:00
parent d15322120f
commit 7a476d777d
6 changed files with 175 additions and 29 deletions

View File

@@ -79,6 +79,8 @@ public class EntityCertificate {
@NonNull
public String data;
static final String OID_BrandIndicatorforMessageIdentification = "1.3.6.1.5.5.7.3.31";
static EntityCertificate from(X509Certificate certificate, String email) throws CertificateEncodingException, NoSuchAlgorithmException {
return from(certificate, false, email);
}
@@ -167,6 +169,21 @@ public class EntityCertificate {
return result;
}
static List<String> getDnsNames(X509Certificate certificate) throws CertificateParsingException {
List<String> result = new ArrayList<>();
Collection<List<?>> altNames = certificate.getSubjectAlternativeNames();
if (altNames == null)
return result;
for (List altName : altNames)
if (altName.get(0).equals(GeneralName.dNSName))
result.add((String) altName.get(1));
return result;
}
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
json.put("id", id);