use of com.google.cloud.security.privateca.v1.Certificate in project TLS-Scanner by RUB-NDS.
the class TrustAnchorManager method getFullCaCertificateSet.
private Set<Certificate> getFullCaCertificateSet() {
Set<Certificate> certificateSet = new HashSet<>();
for (CertificateEntry entry : trustAnchors.values()) {
InputStream resourceAsStream = TrustAnchorManager.class.getClassLoader().getResourceAsStream("trust/" + entry.getFingerprint() + ".pem");
try {
org.bouncycastle.crypto.tls.Certificate cert = PemUtil.readCertificate(resourceAsStream);
certificateSet.add(cert.getCertificateAt(0));
} catch (IOException | CertificateException ex) {
LOGGER.error("Could not load Certificate:" + entry.getSubjectName() + "/" + entry.getFingerprint(), ex);
}
}
return certificateSet;
}
use of com.google.cloud.security.privateca.v1.Certificate in project cloud-security-xsuaa-integration by SAP.
the class SecurityContext method clearCertificate.
/**
* Clears the current Certificate from thread wide storage.
*/
private static void clearCertificate() {
final Certificate certificate = certificateStorage.get();
if (certificate != null) {
LOGGER.debug("Certificate removed from SecurityContext (thread-locally).");
certificateStorage.remove();
}
}
use of com.google.cloud.security.privateca.v1.Certificate in project jruby-openssl by jruby.
the class OCSPRequest method findCertByName.
private java.security.cert.Certificate findCertByName(ASN1Encodable genX500Name, IRubyObject certificates, int flags) throws CertificateException, IOException {
Ruby runtime = getRuntime();
if ((flags & RubyFixnum.fix2int(_OCSP(runtime).getConstant(OCSP_NOINTERN))) == 0) {
ASN1Sequence certs = asn1bcReq.getOptionalSignature().getCerts();
if (certs != null) {
Iterator<ASN1Encodable> it = certs.iterator();
while (it.hasNext()) {
Certificate cert = Certificate.getInstance(it.next());
if (genX500Name.equals(cert.getSubject()))
return new X509AuxCertificate(cert);
}
}
}
@SuppressWarnings("unchecked") List<X509Certificate> certList = (RubyArray) certificates;
for (X509Certificate cert : certList) {
if (genX500Name.equals(X500Name.getInstance(cert.getSubjectX500Principal().getEncoded())))
return new X509AuxCertificate(cert);
}
return null;
}
use of com.google.cloud.security.privateca.v1.Certificate in project cloud-security-xsuaa-integration by SAP.
the class JwtX5tValidator method validate.
/**
* Validates the cnf thumbprint of X509 certificate against trusted
* certificate's thumbprint.
*
* In case audience contains only a single value, thumbprint comparison is not
* performed and request is validated. To guarantee that this single audience is
* trusted, use this validator in combination with {@link JwtAudienceValidator}
*
* @param token
* token to be validated
* @return validation result. Result is valid when both thumbprints match in
* case of multiple audiences.
*/
@Override
public ValidationResult validate(Token token) {
if (token == null) {
return ValidationResults.createInvalid("No token passed to validate certificate thumbprint");
}
String tokenX5t = extractCnfThumbprintFromToken(token);
if (tokenX5t == null) {
return ValidationResults.createInvalid("Token doesn't contain certificate thumbprint confirmation method");
}
Certificate clientCertificate = SecurityContext.getClientCertificate();
if (clientCertificate == null) {
return ValidationResults.createInvalid("Client certificate missing from SecurityContext");
}
String clientCertificateX5t = clientCertificate.getThumbprint();
if (clientCertificateX5t.equals(tokenX5t)) {
return ValidationResults.createValid();
}
return ValidationResults.createInvalid("Certificate thumbprint validation failed with Token 'cnf' thumbprint: {} != {}", tokenX5t, clientCertificateX5t);
}
use of com.google.cloud.security.privateca.v1.Certificate in project ddf by codice.
the class OcspCheckerTest method testConvertingX509CertificatesToBcCertificates.
@Test
public void testConvertingX509CertificatesToBcCertificates() throws Exception {
OcspChecker ocspChecker = new OcspChecker(factory, eventAdmin);
ocspChecker.setSecurityLogger(mock(SecurityLogger.class));
Certificate certificate = ocspChecker.convertToBouncyCastleCert(trustedCertX509);
assertThat(certificate, is(notNullValue()));
assertThat(trustedCertX509.getSerialNumber(), equalTo(certificate.getSerialNumber().getValue()));
assertThat(trustedCertX509.getNotAfter(), equalTo(certificate.getEndDate().getDate()));
assertThat(trustedCertX509.getNotBefore(), equalTo(certificate.getStartDate().getDate()));
X500Principal subjectX500Principal = trustedCertX509.getSubjectX500Principal();
X500Name x500name = new X500Name(subjectX500Principal.getName(X500Principal.RFC1779));
assertThat(x500name, equalTo(certificate.getSubject()));
}
Aggregations