Skip to content

Commit

Permalink
Remove redundant check from P2PX509TrustManager
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuessner committed Jul 29, 2024
1 parent d9d10fb commit cfa3f3f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ object X509Util {
*/
@throws[CertificateException]
def certificateToPublicIdentity(certificate: X509Certificate): PublicIdentity = {
// Certificate still valid?
certificate.checkValidity()

val subject = certificate.getSubjectX500Principal
val issuer = certificate.getIssuerX500Principal

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ class P2PX509TrustManager extends X509TrustManager {
throw CertificateException("Only Ed25519 is supported as signature algo")
if certificate.getVersion != 3 then throw CertificateException("Only X509v3 Certificates are supported")

// Certificate still valid?
certificate.checkValidity()

// Self issued?
val subject = certificate.getSubjectX500Principal
val issuer = certificate.getIssuerX500Principal
if !subject.equals(issuer) then throw CertificateException("certificate not self-issued")

// Verifies that certificate is actually signed by identity in certificate
// Validates and verifies the certificate
val id = X509Util.certificateToPublicIdentity(certificate)
}

Expand Down

0 comments on commit cfa3f3f

Please sign in to comment.