I'm developing an option in one project that encrypts some data using X509Certificate. This project uses Spring Boot. I do encryption with BouncyCastle library.
To encrypt data I have to download recipient's certificate from some server. That's simple, I use Apache HttpClient. But frequent downloads can put a heavy load on the server, so I want to cache this certificate.
I have two methods:
public X509Certificate getFromServer() {
// do some actions...
}
This method downloads certificate from server
public boolean isRevoked(X509Certificate cert) {
// do some actions...
}
This method checks if a certificate has been revoked.
My goal is cache getFromServer method. I need to set up cache eviction policy, that:
- Evicts certificate if it has expired.
- Evict certificate if it has revoked.
Can anyone help me?