Skip to content

Commit

Permalink
[Android] Change cert create time to UTC (#31705)
Browse files Browse the repository at this point in the history
* Change cert create time to UTC

* fix build error
  • Loading branch information
joonhaengHeo authored and pull[bot] committed Feb 5, 2024
1 parent 5bc4a4a commit 2514501
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
import chip.devicecontroller.model.ChipEventPath;
import chip.devicecontroller.model.DataVersionFilter;
import chip.devicecontroller.model.InvokeElement;
import java.time.ZoneOffset;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import java.util.Optional;
import java.util.TimeZone;
import javax.annotation.Nullable;

/** Controller to interact with the CHIP device. */
Expand Down Expand Up @@ -1193,8 +1195,8 @@ public void invoke(
public static byte[] createRootCertificate(
KeypairDelegate keypair, long issuerId, @Nullable Long fabricId) {
// current time
Calendar start = Calendar.getInstance();
Calendar end = Calendar.getInstance();
Calendar start = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
Calendar end = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
// current time + 10 years
end.add(Calendar.YEAR, 10);
return createRootCertificate(keypair, issuerId, fabricId, start, end);
Expand All @@ -1215,9 +1217,9 @@ public static byte[] createIntermediateCertificate(
long issuerId,
@Nullable Long fabricId) {
// current time
Calendar start = Calendar.getInstance();
Calendar start = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
// current time + 10 years
Calendar end = Calendar.getInstance();
Calendar end = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
end.add(Calendar.YEAR, 10);
return createIntermediateCertificate(
rootKeypair, rootCertificate, intermediatePublicKey, issuerId, fabricId, start, end);
Expand Down Expand Up @@ -1251,9 +1253,9 @@ public static byte[] createOperationalCertificate(
long nodeId,
List<Integer> caseAuthenticatedTags) {
// current time
Calendar start = Calendar.getInstance();
Calendar start = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
// current time + 10 years
Calendar end = Calendar.getInstance();
Calendar end = Calendar.getInstance(TimeZone.getTimeZone(ZoneOffset.UTC));
end.add(Calendar.YEAR, 10);
return createOperationalCertificate(
signingKeypair,
Expand Down

0 comments on commit 2514501

Please sign in to comment.