Skip to content

Commit 864de48

Browse files
Fixed processing of issued at and expiration date of certificate (#47)
1 parent dca3e6f commit 864de48

File tree

2 files changed

+2
-21
lines changed

2 files changed

+2
-21
lines changed

.idea/runConfigurations.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

decoder/src/main/java/dgca/verifier/app/decoder/DefaultCertificateDecoder.kt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ import COSE.HeaderKeys
2626
import com.fasterxml.jackson.dataformat.cbor.databind.CBORMapper
2727
import com.upokecenter.cbor.CBORObject
2828
import dgca.verifier.app.decoder.base45.Base45Decoder
29-
import dgca.verifier.app.decoder.cose.CoseService
3029
import dgca.verifier.app.decoder.cwt.CwtHeaderKeys
3130
import dgca.verifier.app.decoder.model.CoseData
3231
import dgca.verifier.app.decoder.model.GreenCertificate
33-
import java.time.Instant
3432
import java.util.zip.InflaterInputStream
3533

3634
@ExperimentalUnsignedTypes
@@ -88,10 +86,10 @@ class DefaultCertificateDecoder(private val base45Decoder: Base45Decoder) :
8886
val messageObject = CBORObject.DecodeFromBytes(this)
8987
val content = messageObject[2].GetByteString()
9088
val rgbProtected = messageObject[0].GetByteString()
91-
var rgbUnprotected = messageObject[1];
89+
val rgbUnprotected = messageObject[1]
9290
val key = HeaderKeys.KID.AsCBOR()
9391

94-
if(!CBORObject.DecodeFromBytes(rgbProtected).keys.contains(key)) {
92+
if (!CBORObject.DecodeFromBytes(rgbProtected).keys.contains(key)) {
9593
val objunprotected = rgbUnprotected.get(key).GetByteString()
9694
return CoseData(content, objunprotected)
9795
}
@@ -101,13 +99,6 @@ class DefaultCertificateDecoder(private val base45Decoder: Base45Decoder) :
10199

102100
private fun ByteArray.decodeGreenCertificate(): GreenCertificate? {
103101
val map = CBORObject.DecodeFromBytes(this)
104-
105-
val issuedAt = Instant.ofEpochSecond(map[CwtHeaderKeys.ISSUED_AT.asCBOR()].AsInt64())
106-
if (issuedAt.isAfter(Instant.now())) throw IllegalArgumentException("IssuedAt not correct: $issuedAt")
107-
108-
val expirationTime = Instant.ofEpochSecond(map[CwtHeaderKeys.EXPIRATION.asCBOR()].AsInt64())
109-
if (expirationTime.isBefore(Instant.now())) throw IllegalArgumentException("Expiration not correct: $expirationTime")
110-
111102
val hcert = map[CwtHeaderKeys.HCERT.asCBOR()]
112103
val hcertv1 = hcert[CBORObject.FromObject(1)].EncodeToBytes()
113104

0 commit comments

Comments
 (0)