Skip to content
This repository has been archived by the owner on Mar 17, 2023. It is now read-only.

Commit

Permalink
Properly handles pubkey with no expiration
Browse files Browse the repository at this point in the history
  • Loading branch information
3TUSK committed Jul 11, 2021
1 parent d2e10ce commit f2fa9b8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
id 'signing'
}

version = '0.1.1'
version = '0.1.2'
group = 'org.teacon'
archivesBaseName = 'RemoteSync-FML'

Expand Down
13 changes: 10 additions & 3 deletions src/main/java/org/teacon/sync/PGPKeyStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,15 @@ private static URL resolveSrv(URL original) {
}

private static boolean hasExpired(PGPPublicKey pubKey) {
Instant creationTime = pubKey.getCreationTime().toInstant();
Instant expirationTime = creationTime.plus(pubKey.getValidSeconds(), ChronoUnit.SECONDS);
return Instant.now().isAfter(expirationTime);
long duration = pubKey.getValidSeconds();
if (duration > 0) {
// Only check expiration if getValidSeconds() returns a positive value
Instant creationTime = pubKey.getCreationTime().toInstant();
Instant expirationTime = creationTime.plus(duration, ChronoUnit.SECONDS);
return Instant.now().isAfter(expirationTime);
} else {
// If getValidSeconds() returns 0 or less it means no expiration.
return false;
}
}
}

0 comments on commit f2fa9b8

Please sign in to comment.