Bug 436043 time errors (certErrorExpired and certErrorNotYetValid) should indicate "now"

show the current time in addition to the unacceptable time
r=kaie
This commit is contained in:
timeless@mozdev.org 2009-09-27 11:23:27 +02:00
Родитель 795daf9ace
Коммит 3802efc70d
2 изменённых файлов: 24 добавлений и 15 удалений

Просмотреть файл

@ -357,8 +357,10 @@ certErrorMismatchSinglePlain=The certificate is only valid for %S
certErrorMismatchMultiple=The certificate is only valid for the following names:
certErrorMismatchNoNames=The certificate is not valid for any server names.
certErrorExpired=The certificate expired on %S.
certErrorNotYetValid=The certificate will not be valid until %S.
# LOCALIZATION NOTE (certErrorExpiredNow): Do not translate %1$S (date+time of expired certificate) or %2$S (current date+time)
certErrorExpiredNow=The certificate expired on %1$S. The current time is %2$S.
# LOCALIZATION NOTE (certErrorNotYetValidNow): Do not translate %1$S (date+time certificate will become valid) or %2$S (current date+time)
certErrorNotYetValidNow=The certificate will not be valid until %1$S. The current time is %2$S.
certErrorCodePrefix=(Error code: %S)

Просмотреть файл

@ -1144,6 +1144,7 @@ AppendErrorTextMismatch(const nsString &host,
static void
GetDateBoundary(nsIX509Cert* ix509,
nsString &formattedDate,
nsString &nowDate,
PRBool &trueExpired_falseNotYetValid)
{
trueExpired_falseNotYetValid = PR_TRUE;
@ -1165,22 +1166,24 @@ GetDateBoundary(nsIX509Cert* ix509,
if (NS_FAILED(rv))
return;
if (LL_CMP(PR_Now(), >, notAfter)) {
PRTime now = PR_Now();
if (LL_CMP(now, >, notAfter)) {
timeToUse = notAfter;
} else {
timeToUse = notBefore;
trueExpired_falseNotYetValid = PR_FALSE;
}
nsIDateTimeFormat* aDateTimeFormat;
rv = CallCreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &aDateTimeFormat);
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat(do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &rv));
if (NS_FAILED(rv))
return;
aDateTimeFormat->FormatPRTime(nsnull, kDateFormatShort,
kTimeFormatNoSeconds, timeToUse,
formattedDate);
NS_IF_RELEASE(aDateTimeFormat);
dateTimeFormat->FormatPRTime(nsnull, kDateFormatShort,
kTimeFormatNoSeconds, timeToUse,
formattedDate);
dateTimeFormat->FormatPRTime(nsnull, kDateFormatShort,
kTimeFormatNoSeconds, now,
nowDate);
}
static void
@ -1188,19 +1191,23 @@ AppendErrorTextTime(nsIX509Cert* ix509,
nsINSSComponent *component,
nsString &returnedMessage)
{
nsAutoString formattedDate;
nsAutoString formattedDate, nowDate;
PRBool trueExpired_falseNotYetValid;
GetDateBoundary(ix509, formattedDate, trueExpired_falseNotYetValid);
GetDateBoundary(ix509, formattedDate, nowDate, trueExpired_falseNotYetValid);
const PRUnichar *params[1];
const PRUnichar *params[2];
params[0] = formattedDate.get(); // might be empty, if helper function had a problem
params[1] = nowDate.get();
const char *key = trueExpired_falseNotYetValid ?
"certErrorExpired" : "certErrorNotYetValid";
"certErrorExpiredNow" : "certErrorNotYetValidNow";
nsresult rv;
nsString formattedString;
rv = component->PIPBundleFormatStringFromName(key, params,
1, formattedString);
rv = component->PIPBundleFormatStringFromName(
key,
params,
NS_ARRAY_LENGTH(params),
formattedString);
if (NS_SUCCEEDED(rv))
{
returnedMessage.Append(formattedString);