-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathSecurity.java
More file actions
27 lines (24 loc) · 934 Bytes
/
Copy pathSecurity.java
File metadata and controls
27 lines (24 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//javax.security.cert to java.security.cert classes migration
package com.amazonaws.samples.appconfig.utils;
import java.security.cert.*;
import java.security.cert.CertificateFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
public class Security {
public Certificate getCertificate(File certFile) throws CertificateExpiredException, CertificateNotYetValidException {
X509Certificate cert = null;
try {
CertificateFactory cf = CertificateFactory.getInstance("X.509");
try (InputStream inStream = new FileInputStream(certFile)) {
cert = (X509Certificate) cf.generateCertificate(inStream);
}
} catch (CertificateException | IOException e) {
throw new RuntimeException(e);
}
cert.checkValidity(new Date());
return cert;
}
}