OLD | NEW |
1 /* | 1 /* |
2 * This file implements the CLIENT Session ID cache. | 2 * This file implements the CLIENT Session ID cache. |
3 * | 3 * |
4 * This Source Code Form is subject to the terms of the Mozilla Public | 4 * This Source Code Form is subject to the terms of the Mozilla Public |
5 * License, v. 2.0. If a copy of the MPL was not distributed with this | 5 * License, v. 2.0. If a copy of the MPL was not distributed with this |
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
7 /* $Id: sslnonce.c,v 1.27 2012/04/25 14:50:12 gerv%gerv.net Exp $ */ | 7 /* $Id$ */ |
8 | 8 |
9 #include "cert.h" | 9 #include "cert.h" |
10 #include "pk11pub.h" | 10 #include "pk11pub.h" |
11 #include "secitem.h" | 11 #include "secitem.h" |
12 #include "ssl.h" | 12 #include "ssl.h" |
13 #include "nss.h" | 13 #include "nss.h" |
14 | 14 |
15 #include "sslimpl.h" | 15 #include "sslimpl.h" |
16 #include "sslproto.h" | 16 #include "sslproto.h" |
17 #include "nssilock.h" | 17 #include "nssilock.h" |
18 #if (defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS
)) && !defined(_WIN32_WCE) | 18 #if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS) |
19 #include <time.h> | 19 #include <time.h> |
20 #endif | 20 #endif |
21 | 21 |
22 PRUint32 ssl_sid_timeout = 100; | 22 PRUint32 ssl_sid_timeout = 100; |
23 PRUint32 ssl3_sid_timeout = 86400L; /* 24 hours */ | 23 PRUint32 ssl3_sid_timeout = 86400L; /* 24 hours */ |
24 | 24 |
25 static sslSessionID *cache = NULL; | 25 static sslSessionID *cache = NULL; |
26 static PZLock * cacheLock = NULL; | 26 static PZLock * cacheLock = NULL; |
27 | 27 |
28 /* sids can be in one of 4 states: | 28 /* sids can be in one of 4 states: |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 181 |
182 if (sid->urlSvrName != NULL) | 182 if (sid->urlSvrName != NULL) |
183 PORT_Free((void *)sid->urlSvrName); /* CONST */ | 183 PORT_Free((void *)sid->urlSvrName); /* CONST */ |
184 | 184 |
185 if ( sid->peerCert ) { | 185 if ( sid->peerCert ) { |
186 CERT_DestroyCertificate(sid->peerCert); | 186 CERT_DestroyCertificate(sid->peerCert); |
187 } | 187 } |
188 for (i = 0; i < MAX_PEER_CERT_CHAIN_SIZE && sid->peerCertChain[i]; i++) { | 188 for (i = 0; i < MAX_PEER_CERT_CHAIN_SIZE && sid->peerCertChain[i]; i++) { |
189 CERT_DestroyCertificate(sid->peerCertChain[i]); | 189 CERT_DestroyCertificate(sid->peerCertChain[i]); |
190 } | 190 } |
| 191 if (sid->peerCertStatus.len) { |
| 192 SECITEM_FreeArray(&sid->peerCertStatus, PR_FALSE); |
| 193 sid->peerCertStatus.items = NULL; |
| 194 sid->peerCertStatus.len = 0; |
| 195 } |
| 196 |
191 if ( sid->localCert ) { | 197 if ( sid->localCert ) { |
192 CERT_DestroyCertificate(sid->localCert); | 198 CERT_DestroyCertificate(sid->localCert); |
193 } | 199 } |
194 if (sid->u.ssl3.sessionTicket.ticket.data) { | 200 if (sid->u.ssl3.sessionTicket.ticket.data) { |
195 SECITEM_FreeItem(&sid->u.ssl3.sessionTicket.ticket, PR_FALSE); | 201 SECITEM_FreeItem(&sid->u.ssl3.sessionTicket.ticket, PR_FALSE); |
196 } | 202 } |
197 if (sid->u.ssl3.srvName.data) { | 203 if (sid->u.ssl3.srvName.data) { |
198 SECITEM_FreeItem(&sid->u.ssl3.srvName, PR_FALSE); | 204 SECITEM_FreeItem(&sid->u.ssl3.srvName, PR_FALSE); |
199 } | 205 } |
200 | 206 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 while(cache != NULL) | 455 while(cache != NULL) |
450 UncacheSID(cache); | 456 UncacheSID(cache); |
451 UNLOCK_CACHE; | 457 UNLOCK_CACHE; |
452 } | 458 } |
453 | 459 |
454 /* returns an unsigned int containing the number of seconds in PR_Now() */ | 460 /* returns an unsigned int containing the number of seconds in PR_Now() */ |
455 PRUint32 | 461 PRUint32 |
456 ssl_Time(void) | 462 ssl_Time(void) |
457 { | 463 { |
458 PRUint32 myTime; | 464 PRUint32 myTime; |
459 #if (defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS
)) && !defined(_WIN32_WCE) | 465 #if defined(XP_UNIX) || defined(XP_WIN) || defined(_WINDOWS) || defined(XP_BEOS) |
460 myTime = time(NULL); /* accurate until the year 2038. */ | 466 myTime = time(NULL); /* accurate until the year 2038. */ |
461 #else | 467 #else |
462 /* portable, but possibly slower */ | 468 /* portable, but possibly slower */ |
463 PRTime now; | 469 PRTime now; |
464 PRInt64 ll; | 470 PRInt64 ll; |
465 | 471 |
466 now = PR_Now(); | 472 now = PR_Now(); |
467 LL_I2L(ll, 1000000L); | 473 LL_I2L(ll, 1000000L); |
468 LL_DIV(now, now, ll); | 474 LL_DIV(now, now, ll); |
469 LL_L2UI(myTime, now); | 475 LL_L2UI(myTime, now); |
(...skipping 26 matching lines...) Expand all Loading... |
496 sid->u.ssl3.sessionTicket.ticket.len = 0; | 502 sid->u.ssl3.sessionTicket.ticket.len = 0; |
497 } | 503 } |
498 sid->u.ssl3.sessionTicket.received_timestamp = | 504 sid->u.ssl3.sessionTicket.received_timestamp = |
499 session_ticket->received_timestamp; | 505 session_ticket->received_timestamp; |
500 sid->u.ssl3.sessionTicket.ticket_lifetime_hint = | 506 sid->u.ssl3.sessionTicket.ticket_lifetime_hint = |
501 session_ticket->ticket_lifetime_hint; | 507 session_ticket->ticket_lifetime_hint; |
502 | 508 |
503 UNLOCK_CACHE; | 509 UNLOCK_CACHE; |
504 return SECSuccess; | 510 return SECSuccess; |
505 } | 511 } |
OLD | NEW |