[FEATURE][EXPERIMENTAL] Проверка CodeSign сертификатов

This commit is contained in:
Gravit 2019-12-04 22:25:17 +07:00
parent cf63e96c1e
commit 40bd92229a
No known key found for this signature in database
GPG key ID: 061981E1E85D3216

View file

@ -9,10 +9,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SignatureException;
import java.security.cert.CertificateEncodingException;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import java.security.cert.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -87,4 +84,15 @@ public boolean isTrusted(X509Certificate certificate) throws CertificateEncoding
public X509Certificate[] getTrusted() {
return Arrays.copyOf(trustSigners, trustSigners.length); // AntiModify orig array!!!
}
public void isCertificateCodeSign(X509Certificate certificate)
{
if(!certificate.getKeyUsage()[0]) throw new SecurityException("Certificate keyUsage \"digitalSignature\" check failed");
List<String> extended;
try {
extended = certificate.getExtendedKeyUsage();
} catch (CertificateParsingException e) {
throw new SecurityException(e);
}
}
}