| 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 | 7 |
| 8 #include "cert.h" | 8 #include "cert.h" |
| 9 #include "pk11pub.h" | 9 #include "pk11pub.h" |
| 10 #include "secitem.h" | 10 #include "secitem.h" |
| (...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 #endif | 434 #endif |
| 435 return myTime; | 435 return myTime; |
| 436 } | 436 } |
| 437 | 437 |
| 438 void | 438 void |
| 439 ssl3_SetSIDSessionTicket(sslSessionID *sid, | 439 ssl3_SetSIDSessionTicket(sslSessionID *sid, |
| 440 /*in/out*/ NewSessionTicket *newSessionTicket) | 440 /*in/out*/ NewSessionTicket *newSessionTicket) |
| 441 { | 441 { |
| 442 PORT_Assert(sid); | 442 PORT_Assert(sid); |
| 443 PORT_Assert(newSessionTicket); | 443 PORT_Assert(newSessionTicket); |
| 444 PORT_Assert(newSessionTicket->ticket.data); |
| 445 PORT_Assert(newSessionTicket->ticket.len != 0); |
| 444 | 446 |
| 445 /* if sid->u.ssl3.lock, we are updating an existing entry that is already | 447 /* if sid->u.ssl3.lock, we are updating an existing entry that is already |
| 446 * cached or was once cached, so we need to acquire and release the write | 448 * cached or was once cached, so we need to acquire and release the write |
| 447 * lock. Otherwise, this is a new session that isn't shared with anything | 449 * lock. Otherwise, this is a new session that isn't shared with anything |
| 448 * yet, so no locking is needed. | 450 * yet, so no locking is needed. |
| 449 */ | 451 */ |
| 450 if (sid->u.ssl3.lock) { | 452 if (sid->u.ssl3.lock) { |
| 451 NSSRWLock_LockWrite(sid->u.ssl3.lock); | 453 NSSRWLock_LockWrite(sid->u.ssl3.lock); |
| 452 | |
| 453 /* A server might have sent us an empty ticket, which has the | |
| 454 * effect of clearing the previously known ticket. | |
| 455 */ | |
| 456 if (sid->u.ssl3.locked.sessionTicket.ticket.data) { | 454 if (sid->u.ssl3.locked.sessionTicket.ticket.data) { |
| 457 SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket, | 455 SECITEM_FreeItem(&sid->u.ssl3.locked.sessionTicket.ticket, |
| 458 PR_FALSE); | 456 PR_FALSE); |
| 459 } | 457 } |
| 460 } | 458 } |
| 461 | 459 |
| 462 PORT_Assert(!sid->u.ssl3.locked.sessionTicket.ticket.data); | 460 PORT_Assert(!sid->u.ssl3.locked.sessionTicket.ticket.data); |
| 463 | 461 |
| 464 /* Do a shallow copy, moving the ticket data. */ | 462 /* Do a shallow copy, moving the ticket data. */ |
| 465 sid->u.ssl3.locked.sessionTicket = *newSessionTicket; | 463 sid->u.ssl3.locked.sessionTicket = *newSessionTicket; |
| 466 newSessionTicket->ticket.data = NULL; | 464 newSessionTicket->ticket.data = NULL; |
| 467 newSessionTicket->ticket.len = 0; | 465 newSessionTicket->ticket.len = 0; |
| 468 | 466 |
| 469 if (sid->u.ssl3.lock) { | 467 if (sid->u.ssl3.lock) { |
| 470 NSSRWLock_UnlockWrite(sid->u.ssl3.lock); | 468 NSSRWLock_UnlockWrite(sid->u.ssl3.lock); |
| 471 } | 469 } |
| 472 } | 470 } |
| OLD | NEW |