Skip to content

Commit f4b715f

Browse files
authored
Fix OCSP test responder to omit fractional seconds
1 parent 0bb8df7 commit f4b715f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/libraries/Common/tests/System/Security/Cryptography/X509Certificates/CertificateAuthority.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,18 @@ singleExtensions [1] EXPLICIT Extensions OPTIONAL }
566566
}
567567
else if (status == CertStatus.Revoked)
568568
{
569-
// Android does not support all precisions for seconds - just omit fractional seconds for testing on Android
570569
writer.PushSequence(s_context1);
571-
writer.WriteGeneralizedTime(revokedTime, omitFractionalSeconds: OperatingSystem.IsAndroid());
570+
571+
// Fracational seconds "MUST NOT" be used here. Android and macOS 13+ enforce this and
572+
// reject GeneralizedTime's with fractional seconds, so omit them.
573+
// RFC 6960: 4.2.2.1:
574+
// The format for GeneralizedTime is as specified in Section 4.1.2.5.2 of [RFC5280].
575+
// RFC 5280 4.1.2.5.2:
576+
// For the purposes of this profile, GeneralizedTime values MUST be
577+
// expressed in Greenwich Mean Time (Zulu) and MUST include seconds
578+
// (i.e., times are YYYYMMDDHHMMSSZ), even where the number of seconds
579+
// is zero. GeneralizedTime values MUST NOT include fractional seconds.
580+
writer.WriteGeneralizedTime(revokedTime, omitFractionalSeconds: true);
572581
writer.PopSequence(s_context1);
573582
}
574583
else

0 commit comments

Comments
 (0)