Skip to content

Commit

Permalink
Handle error responses from tsa by using local machine time.
Browse files Browse the repository at this point in the history
  • Loading branch information
bpvgoncalves committed Oct 9, 2023
1 parent cad6738 commit d49cf1a
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions R/tsp.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ get_timestamp_secure <- function(tsq) {

if(resp$status_code == 200L) {
tsr <- PKI::ASN1.decode(resp$body)
ts <- PKI::ASN1.decode(PKI::ASN1.decode(PKI::ASN1.decode(tsr[[2]][[2]])[[3]][[2]]))[[5]]
ts <- as.POSIXct(rawToChar(ts), format = "%Y%m%d%H%M%SZ", tz="UTC")
if (tsr[[1]][[1]] == 0) {
# PKIStatus ::= INTEGER { granted (0), grantedWithMods (1), rejection (2), waiting (3),
# revocationWarning (4), revocationNotification (5) }
ts <- PKI::ASN1.decode(PKI::ASN1.decode(PKI::ASN1.decode(tsr[[2]][[2]])[[3]][[2]]))[[5]]
ts <- as.POSIXct(rawToChar(ts), format = "%Y%m%d%H%M%SZ", tz="UTC")

out <- list(ts = structure(strftime(ts, "%Y-%m-%dT%H:%M:%SZ", tz="UTC"),
unix_ts = as.integer(ts),
class = "pqcrypto_timestamp"),
tsr = structure(resp$body,
class = "pqcrypto_tsp_tsr"))
out <- list(ts = structure(strftime(ts, "%Y-%m-%dT%H:%M:%SZ", tz="UTC"),
unix_ts = as.integer(ts),
class = "pqcrypto_timestamp"),
tsr = structure(resp$body,
class = "pqcrypto_tsp_tsr"))
} else {
out <- list(ts = get_timestamp(),
tsr = NULL)
}
} else {
out <- list(ts = get_timestamp(),
tsr = NULL)
Expand Down

0 comments on commit d49cf1a

Please sign in to comment.