summaryrefslogtreecommitdiffstats
path: root/luni
diff options
context:
space:
mode:
authorKenny Root <kroot@google.com>2013-04-15 10:31:37 -0700
committerKenny Root <kroot@google.com>2013-04-15 12:44:47 -0700
commit674979bffe6f45df0beaf79128b86770d7f7cec9 (patch)
treecb8b03f78f93fbc363ea1531e8d146e60de9786d /luni
parent7558d01692af3efc287653e79dd344932145c4c3 (diff)
downloadlibcore-674979bffe6f45df0beaf79128b86770d7f7cec9.zip
libcore-674979bffe6f45df0beaf79128b86770d7f7cec9.tar.gz
libcore-674979bffe6f45df0beaf79128b86770d7f7cec9.tar.bz2
NativeCrypto: set Calendar instances to 0 millis
X.509 does not have a notion of milliseconds so it was not being set through the Calendar instances we used in OpenSSLX509Certificate, et al. Instead it was getting whatever the current millisecond offset was from the GregorianCalendar default constructor. That made two parsed certificates unlikely to be equal when comparing since the milliseconds were also checked. (cherry picked from commit 3725893865ddbdd2e9cebc2ea2f7ecfc357fcfbb) Bug: 8616647 Change-Id: Ia914856a560526718957607d69401eab8c2830cf
Diffstat (limited to 'luni')
-rw-r--r--luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRL.java8
-rw-r--r--luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRLEntry.java4
-rw-r--r--luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509Certificate.java8
3 files changed, 10 insertions, 10 deletions
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRL.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRL.java
index 9d6b6b8..04418c7 100644
--- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRL.java
+++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRL.java
@@ -259,8 +259,8 @@ public class OpenSSLX509CRL extends X509CRL {
@Override
public Date getThisUpdate() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.set(Calendar.MILLISECOND, 0);
NativeCrypto.ASN1_TIME_to_Calendar(NativeCrypto.X509_CRL_get_lastUpdate(mContext),
calendar);
return calendar.getTime();
@@ -268,8 +268,8 @@ public class OpenSSLX509CRL extends X509CRL {
@Override
public Date getNextUpdate() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.set(Calendar.MILLISECOND, 0);
NativeCrypto.ASN1_TIME_to_Calendar(NativeCrypto.X509_CRL_get_nextUpdate(mContext),
calendar);
return calendar.getTime();
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRLEntry.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRLEntry.java
index 3655338..4965200 100644
--- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRLEntry.java
+++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509CRLEntry.java
@@ -106,8 +106,8 @@ public class OpenSSLX509CRLEntry extends X509CRLEntry {
@Override
public Date getRevocationDate() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.set(Calendar.MILLISECOND, 0);
NativeCrypto.ASN1_TIME_to_Calendar(NativeCrypto.get_X509_REVOKED_revocationDate(mContext),
calendar);
return calendar.getTime();
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509Certificate.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509Certificate.java
index e9aa24d..daeb049 100644
--- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509Certificate.java
+++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLX509Certificate.java
@@ -242,16 +242,16 @@ public class OpenSSLX509Certificate extends X509Certificate {
@Override
public Date getNotBefore() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.set(Calendar.MILLISECOND, 0);
NativeCrypto.ASN1_TIME_to_Calendar(NativeCrypto.X509_get_notBefore(mContext), calendar);
return calendar.getTime();
}
@Override
public Date getNotAfter() {
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ calendar.set(Calendar.MILLISECOND, 0);
NativeCrypto.ASN1_TIME_to_Calendar(NativeCrypto.X509_get_notAfter(mContext), calendar);
return calendar.getTime();
}