OLD | NEW |
1 /* | 1 /* |
2 * Various SSL functions. | 2 * Various SSL functions. |
3 * | 3 * |
4 * ***** BEGIN LICENSE BLOCK ***** | 4 * ***** BEGIN LICENSE BLOCK ***** |
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
6 * | 6 * |
7 * The contents of this file are subject to the Mozilla Public License Version | 7 * The contents of this file are subject to the Mozilla Public License Version |
8 * 1.1 (the "License"); you may not use this file except in compliance with | 8 * 1.1 (the "License"); you may not use this file except in compliance with |
9 * the License. You may obtain a copy of the License at | 9 * the License. You may obtain a copy of the License at |
10 * http://www.mozilla.org/MPL/ | 10 * http://www.mozilla.org/MPL/ |
(...skipping 19 matching lines...) Expand all Loading... |
30 * in which case the provisions of the GPL or the LGPL are applicable instead | 30 * in which case the provisions of the GPL or the LGPL are applicable instead |
31 * of those above. If you wish to allow use of your version of this file only | 31 * of those above. If you wish to allow use of your version of this file only |
32 * under the terms of either the GPL or the LGPL, and not to allow others to | 32 * under the terms of either the GPL or the LGPL, and not to allow others to |
33 * use your version of this file under the terms of the MPL, indicate your | 33 * use your version of this file under the terms of the MPL, indicate your |
34 * decision by deleting the provisions above and replace them with the notice | 34 * decision by deleting the provisions above and replace them with the notice |
35 * and other provisions required by the GPL or the LGPL. If you do not delete | 35 * and other provisions required by the GPL or the LGPL. If you do not delete |
36 * the provisions above, a recipient may use your version of this file under | 36 * the provisions above, a recipient may use your version of this file under |
37 * the terms of any one of the MPL, the GPL or the LGPL. | 37 * the terms of any one of the MPL, the GPL or the LGPL. |
38 * | 38 * |
39 * ***** END LICENSE BLOCK ***** */ | 39 * ***** END LICENSE BLOCK ***** */ |
40 /* $Id: sslsecur.c,v 1.43.2.2 2010/08/26 18:06:55 wtc%google.com Exp $ */ | 40 /* $Id: sslsecur.c,v 1.57 2012/02/15 21:52:08 kaie%kuix.de Exp $ */ |
41 #include "cert.h" | 41 #include "cert.h" |
42 #include "secitem.h" | 42 #include "secitem.h" |
43 #include "keyhi.h" | 43 #include "keyhi.h" |
44 #include "ssl.h" | 44 #include "ssl.h" |
45 #include "sslimpl.h" | 45 #include "sslimpl.h" |
46 #include "sslproto.h" | 46 #include "sslproto.h" |
47 #include "secoid.h" /* for SECOID_GetALgorithmTag */ | 47 #include "secoid.h" /* for SECOID_GetALgorithmTag */ |
48 #include "pk11func.h" /* for PK11_GenerateRandom */ | 48 #include "pk11func.h" /* for PK11_GenerateRandom */ |
49 #include "nss.h" /* for NSS_RegisterShutdown */ | 49 #include "nss.h" /* for NSS_RegisterShutdown */ |
50 #include "prinit.h" /* for PR_CallOnceWithArg */ | 50 #include "prinit.h" /* for PR_CallOnceWithArg */ |
(...skipping 26 matching lines...) Expand all Loading... |
77 * 1. ssl_GatherRecord1stHandshake called ssl2_GatherData which read in | 77 * 1. ssl_GatherRecord1stHandshake called ssl2_GatherData which read in |
78 * the beginning of an SSL v3 hello message and returned SECWouldBlock | 78 * the beginning of an SSL v3 hello message and returned SECWouldBlock |
79 * to switch to SSL v3 handshake processing. | 79 * to switch to SSL v3 handshake processing. |
80 * | 80 * |
81 * 2. ssl2_HandleClientHelloMessage discovered version 3.0 in the incoming | 81 * 2. ssl2_HandleClientHelloMessage discovered version 3.0 in the incoming |
82 * v2 client hello msg, and called ssl3_HandleV2ClientHello which | 82 * v2 client hello msg, and called ssl3_HandleV2ClientHello which |
83 * returned SECWouldBlock. | 83 * returned SECWouldBlock. |
84 * | 84 * |
85 * 3. SECWouldBlock was returned by one of the callback functions, via | 85 * 3. SECWouldBlock was returned by one of the callback functions, via |
86 * one of these paths: | 86 * one of these paths: |
87 * -» ssl2_HandleMessage() -> ssl2_HandleRequestCertificate() -> ss->getClient
AuthData() | 87 * -» ssl2_HandleMessage() -> ssl2_HandleRequestCertificate() -> |
| 88 *» ss->getClientAuthData() |
88 * | 89 * |
89 * - ssl2_HandleServerHelloMessage() -> ss->handleBadCert() | 90 * - ssl2_HandleServerHelloMessage() -> ss->handleBadCert() |
90 * | 91 * |
91 * - ssl_GatherRecord1stHandshake() -> ssl3_GatherCompleteHandshake() -> | 92 * - ssl_GatherRecord1stHandshake() -> ssl3_GatherCompleteHandshake() -> |
92 * ssl3_HandleRecord() -> ssl3_HandleHandshake() -> | 93 * ssl3_HandleRecord() -> ssl3_HandleHandshake() -> |
93 * ssl3_HandleHandshakeMessage() -> ssl3_HandleCertificate() -> | 94 * ssl3_HandleHandshakeMessage() -> ssl3_HandleCertificate() -> |
94 * ss->handleBadCert() | 95 * ss->handleBadCert() |
95 * | 96 * |
96 * - ssl_GatherRecord1stHandshake() -> ssl3_GatherCompleteHandshake() -> | 97 * - ssl_GatherRecord1stHandshake() -> ssl3_GatherCompleteHandshake() -> |
97 * ssl3_HandleRecord() -> ssl3_HandleHandshake() -> | 98 * ssl3_HandleRecord() -> ssl3_HandleHandshake() -> |
(...skipping 12 matching lines...) Expand all Loading... |
110 int | 111 int |
111 ssl_Do1stHandshake(sslSocket *ss) | 112 ssl_Do1stHandshake(sslSocket *ss) |
112 { | 113 { |
113 int rv = SECSuccess; | 114 int rv = SECSuccess; |
114 int loopCount = 0; | 115 int loopCount = 0; |
115 | 116 |
116 do { | 117 do { |
117 PORT_Assert(ss->opt.noLocks || ssl_Have1stHandshakeLock(ss) ); | 118 PORT_Assert(ss->opt.noLocks || ssl_Have1stHandshakeLock(ss) ); |
118 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); | 119 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); |
119 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); | 120 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); |
| 121 PORT_Assert(ss->opt.noLocks || !ssl_HaveSSL3HandshakeLock(ss)); |
120 | 122 |
121 if (ss->handshake == 0) { | 123 if (ss->handshake == 0) { |
122 /* Previous handshake finished. Switch to next one */ | 124 /* Previous handshake finished. Switch to next one */ |
123 ss->handshake = ss->nextHandshake; | 125 ss->handshake = ss->nextHandshake; |
124 ss->nextHandshake = 0; | 126 ss->nextHandshake = 0; |
125 } | 127 } |
126 if (ss->handshake == 0) { | 128 if (ss->handshake == 0) { |
127 /* Previous handshake finished. Switch to security handshake */ | 129 /* Previous handshake finished. Switch to security handshake */ |
128 ss->handshake = ss->securityHandshake; | 130 ss->handshake = ss->securityHandshake; |
129 ss->securityHandshake = 0; | 131 ss->securityHandshake = 0; |
(...skipping 20 matching lines...) Expand all Loading... |
150 } | 152 } |
151 rv = (*ss->handshake)(ss); | 153 rv = (*ss->handshake)(ss); |
152 ++loopCount; | 154 ++loopCount; |
153 /* This code must continue to loop on SECWouldBlock, | 155 /* This code must continue to loop on SECWouldBlock, |
154 * or any positive value. See XXX_1 comments. | 156 * or any positive value. See XXX_1 comments. |
155 */ | 157 */ |
156 } while (rv != SECFailure); /* was (rv >= 0); XXX_1 */ | 158 } while (rv != SECFailure); /* was (rv >= 0); XXX_1 */ |
157 | 159 |
158 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); | 160 PORT_Assert(ss->opt.noLocks || !ssl_HaveRecvBufLock(ss)); |
159 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); | 161 PORT_Assert(ss->opt.noLocks || !ssl_HaveXmitBufLock(ss)); |
| 162 PORT_Assert(ss->opt.noLocks || !ssl_HaveSSL3HandshakeLock(ss)); |
160 | 163 |
161 if (rv == SECWouldBlock) { | 164 if (rv == SECWouldBlock) { |
162 PORT_SetError(PR_WOULD_BLOCK_ERROR); | 165 PORT_SetError(PR_WOULD_BLOCK_ERROR); |
163 rv = SECFailure; | 166 rv = SECFailure; |
164 } | 167 } |
165 return rv; | 168 return rv; |
166 } | 169 } |
167 | 170 |
168 /* | 171 /* |
169 * Handshake function that blocks. Used to force a | 172 * Handshake function that blocks. Used to force a |
170 * retry on a connection on the next read/write. | 173 * retry on a connection on the next read/write. |
171 */ | 174 */ |
172 static SECStatus | 175 static SECStatus |
173 AlwaysBlock(sslSocket *ss) | 176 ssl3_AlwaysBlock(sslSocket *ss) |
174 { | 177 { |
175 PORT_SetError(PR_WOULD_BLOCK_ERROR); /* perhaps redundant. */ | 178 PORT_SetError(PR_WOULD_BLOCK_ERROR); /* perhaps redundant. */ |
176 return SECWouldBlock; | 179 return SECWouldBlock; |
177 } | 180 } |
178 | 181 |
179 /* | 182 /* |
180 * set the initial handshake state machine to block | 183 * set the initial handshake state machine to block |
181 */ | 184 */ |
182 void | 185 void |
183 ssl_SetAlwaysBlock(sslSocket *ss) | 186 ssl3_SetAlwaysBlock(sslSocket *ss) |
184 { | 187 { |
185 if (!ss->firstHsDone) { | 188 if (!ss->firstHsDone) { |
186 » ss->handshake = AlwaysBlock; | 189 » ss->handshake = ssl3_AlwaysBlock; |
187 ss->nextHandshake = 0; | 190 ss->nextHandshake = 0; |
188 } | 191 } |
189 } | 192 } |
190 | 193 |
191 static SECStatus | 194 static SECStatus |
192 ssl_SetTimeout(PRFileDesc *fd, PRIntervalTime timeout) | 195 ssl_SetTimeout(PRFileDesc *fd, PRIntervalTime timeout) |
193 { | 196 { |
194 sslSocket *ss; | 197 sslSocket *ss; |
195 | 198 |
196 ss = ssl_FindSocket(fd); | 199 ss = ssl_FindSocket(fd); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 231 |
229 /* Don't waste my time */ | 232 /* Don't waste my time */ |
230 if (!ss->opt.useSecurity) | 233 if (!ss->opt.useSecurity) |
231 return SECSuccess; | 234 return SECSuccess; |
232 | 235 |
233 SSL_LOCK_READER(ss); | 236 SSL_LOCK_READER(ss); |
234 SSL_LOCK_WRITER(ss); | 237 SSL_LOCK_WRITER(ss); |
235 | 238 |
236 /* Reset handshake state */ | 239 /* Reset handshake state */ |
237 ssl_Get1stHandshakeLock(ss); | 240 ssl_Get1stHandshakeLock(ss); |
238 ssl_GetSSL3HandshakeLock(ss); | |
239 | 241 |
240 ss->firstHsDone = PR_FALSE; | 242 ss->firstHsDone = PR_FALSE; |
241 if ( asServer ) { | 243 if ( asServer ) { |
242 ss->handshake = ssl2_BeginServerHandshake; | 244 ss->handshake = ssl2_BeginServerHandshake; |
243 ss->handshaking = sslHandshakingAsServer; | 245 ss->handshaking = sslHandshakingAsServer; |
244 } else { | 246 } else { |
245 ss->handshake = ssl2_BeginClientHandshake; | 247 ss->handshake = ssl2_BeginClientHandshake; |
246 ss->handshaking = sslHandshakingAsClient; | 248 ss->handshaking = sslHandshakingAsClient; |
247 } | 249 } |
248 ss->nextHandshake = 0; | 250 ss->nextHandshake = 0; |
249 ss->securityHandshake = 0; | 251 ss->securityHandshake = 0; |
250 | 252 |
251 ssl_GetRecvBufLock(ss); | 253 ssl_GetRecvBufLock(ss); |
252 status = ssl_InitGather(&ss->gs); | 254 status = ssl_InitGather(&ss->gs); |
253 ssl_ReleaseRecvBufLock(ss); | 255 ssl_ReleaseRecvBufLock(ss); |
254 | 256 |
| 257 ssl_GetSSL3HandshakeLock(ss); |
| 258 |
255 /* | 259 /* |
256 ** Blow away old security state and get a fresh setup. | 260 ** Blow away old security state and get a fresh setup. |
257 */ | 261 */ |
258 ssl_GetXmitBufLock(ss); | 262 ssl_GetXmitBufLock(ss); |
259 ssl_ResetSecurityInfo(&ss->sec, PR_TRUE); | 263 ssl_ResetSecurityInfo(&ss->sec, PR_TRUE); |
260 status = ssl_CreateSecurityInfo(ss); | 264 status = ssl_CreateSecurityInfo(ss); |
261 ssl_ReleaseXmitBufLock(ss); | 265 ssl_ReleaseXmitBufLock(ss); |
262 | 266 |
263 ssl_ReleaseSSL3HandshakeLock(ss); | 267 ssl_ReleaseSSL3HandshakeLock(ss); |
264 ssl_Release1stHandshakeLock(ss); | 268 ssl_Release1stHandshakeLock(ss); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 PORT_Assert(SECSuccess == rv); | 683 PORT_Assert(SECSuccess == rv); |
680 if (SECSuccess == rv) { | 684 if (SECSuccess == rv) { |
681 ssl3_server_ca_list = CERT_GetSSLCACerts(dbHandle); | 685 ssl3_server_ca_list = CERT_GetSSLCACerts(dbHandle); |
682 return PR_SUCCESS; | 686 return PR_SUCCESS; |
683 } | 687 } |
684 return PR_FAILURE; | 688 return PR_FAILURE; |
685 } | 689 } |
686 | 690 |
687 SECStatus | 691 SECStatus |
688 ssl_ConfigSecureServer(sslSocket *ss, CERTCertificate *cert, | 692 ssl_ConfigSecureServer(sslSocket *ss, CERTCertificate *cert, |
689 CERTCertificateList *certChain, | 693 const CERTCertificateList *certChain, |
690 ssl3KeyPair *keyPair, SSLKEAType kea) | 694 ssl3KeyPair *keyPair, SSLKEAType kea) |
691 { | 695 { |
692 CERTCertificateList *localCertChain = NULL; | 696 CERTCertificateList *localCertChain = NULL; |
693 sslServerCerts *sc = ss->serverCerts + kea; | 697 sslServerCerts *sc = ss->serverCerts + kea; |
694 | 698 |
695 /* load the server certificate */ | 699 /* load the server certificate */ |
696 if (sc->serverCert != NULL) { | 700 if (sc->serverCert != NULL) { |
697 CERT_DestroyCertificate(sc->serverCert); | 701 CERT_DestroyCertificate(sc->serverCert); |
698 sc->serverCert = NULL; | 702 sc->serverCert = NULL; |
699 sc->serverKeyBits = 0; | 703 sc->serverKeyBits = 0; |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 761 } |
758 return SECFailure; | 762 return SECFailure; |
759 } | 763 } |
760 | 764 |
761 /* XXX need to protect the data that gets changed here.!! */ | 765 /* XXX need to protect the data that gets changed here.!! */ |
762 | 766 |
763 SECStatus | 767 SECStatus |
764 SSL_ConfigSecureServer(PRFileDesc *fd, CERTCertificate *cert, | 768 SSL_ConfigSecureServer(PRFileDesc *fd, CERTCertificate *cert, |
765 SECKEYPrivateKey *key, SSL3KEAType kea) | 769 SECKEYPrivateKey *key, SSL3KEAType kea) |
766 { | 770 { |
| 771 |
| 772 return SSL_ConfigSecureServerWithCertChain(fd, cert, NULL, key, kea); |
| 773 } |
| 774 |
| 775 SECStatus |
| 776 SSL_ConfigSecureServerWithCertChain(PRFileDesc *fd, CERTCertificate *cert, |
| 777 const CERTCertificateList *certChainOpt, |
| 778 SECKEYPrivateKey *key, SSL3KEAType kea) |
| 779 { |
767 sslSocket *ss; | 780 sslSocket *ss; |
768 SECKEYPublicKey *pubKey = NULL; | 781 SECKEYPublicKey *pubKey = NULL; |
769 ssl3KeyPair *keyPair = NULL; | 782 ssl3KeyPair *keyPair = NULL; |
770 SECStatus rv = SECFailure; | 783 SECStatus rv = SECFailure; |
771 | 784 |
772 ss = ssl_FindSocket(fd); | 785 ss = ssl_FindSocket(fd); |
773 if (!ss) { | 786 if (!ss) { |
774 return SECFailure; | 787 return SECFailure; |
775 } | 788 } |
776 | 789 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 keyCopy = SECKEY_CopyPrivateKey(key); | 840 keyCopy = SECKEY_CopyPrivateKey(key); |
828 if (keyCopy == NULL) | 841 if (keyCopy == NULL) |
829 goto loser; | 842 goto loser; |
830 keyPair = ssl3_NewKeyPair(keyCopy, pubKey); | 843 keyPair = ssl3_NewKeyPair(keyCopy, pubKey); |
831 if (keyPair == NULL) { | 844 if (keyPair == NULL) { |
832 SECKEY_DestroyPrivateKey(keyCopy); | 845 SECKEY_DestroyPrivateKey(keyCopy); |
833 goto loser; | 846 goto loser; |
834 } | 847 } |
835 pubKey = NULL; /* adopted by serverKeyPair */ | 848 pubKey = NULL; /* adopted by serverKeyPair */ |
836 } | 849 } |
837 if (ssl_ConfigSecureServer(ss, cert, NULL, | 850 if (ssl_ConfigSecureServer(ss, cert, certChainOpt, |
838 keyPair, kea) == SECFailure) { | 851 keyPair, kea) == SECFailure) { |
839 goto loser; | 852 goto loser; |
840 } | 853 } |
841 | 854 |
842 /* Only do this once because it's global. */ | 855 /* Only do this once because it's global. */ |
843 if (PR_SUCCESS == PR_CallOnceWithArg(&setupServerCAListOnce, | 856 if (PR_SUCCESS == PR_CallOnceWithArg(&setupServerCAListOnce, |
844 &serverCAListSetup, | 857 &serverCAListSetup, |
845 (void *)(ss->dbHandle))) { | 858 (void *)(ss->dbHandle))) { |
846 rv = SECSuccess; | 859 rv = SECSuccess; |
847 } | 860 } |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 if (rv < 0) { | 1218 if (rv < 0) { |
1206 goto done; | 1219 goto done; |
1207 } | 1220 } |
1208 | 1221 |
1209 if (len > 0) | 1222 if (len > 0) |
1210 ss->writerThread = PR_GetCurrentThread(); | 1223 ss->writerThread = PR_GetCurrentThread(); |
1211 /* If any of these is non-zero, the initial handshake is not done. */ | 1224 /* If any of these is non-zero, the initial handshake is not done. */ |
1212 if (!ss->firstHsDone) { | 1225 if (!ss->firstHsDone) { |
1213 PRBool canFalseStart = PR_FALSE; | 1226 PRBool canFalseStart = PR_FALSE; |
1214 ssl_Get1stHandshakeLock(ss); | 1227 ssl_Get1stHandshakeLock(ss); |
1215 » if (ss->version >= SSL_LIBRARY_VERSION_3_0 && | 1228 » if (ss->version >= SSL_LIBRARY_VERSION_3_0) { |
1216 » (ss->ssl3.hs.ws == wait_change_cipher || | 1229 » ssl_GetSSL3HandshakeLock(ss); |
1217 » ss->ssl3.hs.ws == wait_finished || | 1230 » if ((ss->ssl3.hs.ws == wait_change_cipher || |
1218 » ss->ssl3.hs.ws == wait_new_session_ticket) && | 1231 » » ss->ssl3.hs.ws == wait_finished || |
1219 » ssl3_CanFalseStart(ss)) { | 1232 » » ss->ssl3.hs.ws == wait_new_session_ticket) && |
1220 » canFalseStart = PR_TRUE; | 1233 » » ssl3_CanFalseStart(ss)) { |
| 1234 » » canFalseStart = PR_TRUE; |
| 1235 » } |
| 1236 » ssl_ReleaseSSL3HandshakeLock(ss); |
1221 } | 1237 } |
1222 if (!canFalseStart && | 1238 if (!canFalseStart && |
1223 (ss->handshake || ss->nextHandshake || ss->securityHandshake)) { | 1239 (ss->handshake || ss->nextHandshake || ss->securityHandshake)) { |
1224 rv = ssl_Do1stHandshake(ss); | 1240 rv = ssl_Do1stHandshake(ss); |
1225 } | 1241 } |
1226 ssl_Release1stHandshakeLock(ss); | 1242 ssl_Release1stHandshakeLock(ss); |
1227 } | 1243 } |
1228 if (rv < 0) { | 1244 if (rv < 0) { |
1229 ss->writerThread = NULL; | 1245 ss->writerThread = NULL; |
1230 goto done; | 1246 goto done; |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1503 } | 1519 } |
1504 | 1520 |
1505 ssl_Get1stHandshakeLock(ss); /************************************/ | 1521 ssl_Get1stHandshakeLock(ss); /************************************/ |
1506 | 1522 |
1507 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { | 1523 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { |
1508 ret = ssl3_RestartHandshakeAfterCertReq(ss, cert, key, certChain); | 1524 ret = ssl3_RestartHandshakeAfterCertReq(ss, cert, key, certChain); |
1509 } else { | 1525 } else { |
1510 if (certChain != NULL) { | 1526 if (certChain != NULL) { |
1511 CERT_DestroyCertificateList(certChain); | 1527 CERT_DestroyCertificateList(certChain); |
1512 } | 1528 } |
1513 » ret = ssl2_RestartHandshakeAfterCertReq(ss, cert, key); | 1529 » PORT_SetError(SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SSL2); |
| 1530 » ret = SECFailure; |
1514 } | 1531 } |
1515 | 1532 |
1516 ssl_Release1stHandshakeLock(ss); /************************************/ | 1533 ssl_Release1stHandshakeLock(ss); /************************************/ |
1517 return ret; | 1534 return ret; |
1518 } | 1535 } |
1519 | 1536 |
| 1537 /* DO NOT USE. This function was exported in ssl.def with the wrong signature; |
| 1538 * this implementation exists to maintain link-time compatibility. |
| 1539 */ |
| 1540 int |
| 1541 SSL_RestartHandshakeAfterServerCert(sslSocket * ss) |
| 1542 { |
| 1543 PORT_SetError(PR_NOT_IMPLEMENTED_ERROR); |
| 1544 return -1; |
| 1545 } |
1520 | 1546 |
1521 /* restart an SSL connection that we stopped to run certificate dialogs | 1547 /* See documentation in ssl.h */ |
1522 ** XXX» Need to document here how an application marks a cert to show that | 1548 SECStatus |
1523 **» the application has accepted it (overridden CERT_VerifyCert). | 1549 SSL_AuthCertificateComplete(PRFileDesc *fd, PRErrorCode error) |
1524 * | |
1525 * XXX This code only works on the initial handshake on a connection, XXX | |
1526 * It does not work on a subsequent handshake (redo). | |
1527 * | |
1528 * Return value: XXX | |
1529 */ | |
1530 int | |
1531 SSL_RestartHandshakeAfterServerCert(sslSocket *ss) | |
1532 { | 1550 { |
1533 int rv» = SECSuccess; | 1551 SECStatus rv; |
| 1552 sslSocket *ss = ssl_FindSocket(fd); |
1534 | 1553 |
1535 ssl_Get1stHandshakeLock(ss); | 1554 if (!ss) { |
| 1555 » SSL_DBG(("%d: SSL[%d]: bad socket in SSL_AuthCertificateComplete", |
| 1556 » » SSL_GETPID(), fd)); |
| 1557 » return SECFailure; |
| 1558 } |
1536 | 1559 |
1537 if (ss->version >= SSL_LIBRARY_VERSION_3_0) { | 1560 ssl_Get1stHandshakeLock(ss); |
1538 » rv = ssl3_RestartHandshakeAfterServerCert(ss); | 1561 |
| 1562 if (!ss->ssl3.initialized) { |
| 1563 » PORT_SetError(SEC_ERROR_INVALID_ARGS); |
| 1564 » rv = SECFailure; |
| 1565 } else if (ss->version < SSL_LIBRARY_VERSION_3_0) { |
| 1566 » PORT_SetError(SSL_ERROR_FEATURE_NOT_SUPPORTED_FOR_SSL2); |
| 1567 » rv = SECFailure; |
1539 } else { | 1568 } else { |
1540 » rv = ssl2_RestartHandshakeAfterServerCert(ss); | 1569 » rv = ssl3_AuthCertificateComplete(ss, error); |
1541 } | 1570 } |
1542 | 1571 |
1543 ssl_Release1stHandshakeLock(ss); | 1572 ssl_Release1stHandshakeLock(ss); |
| 1573 |
1544 return rv; | 1574 return rv; |
1545 } | 1575 } |
1546 | 1576 |
1547 /* For more info see ssl.h */ | 1577 /* For more info see ssl.h */ |
1548 SECStatus | 1578 SECStatus |
1549 SSL_SNISocketConfigHook(PRFileDesc *fd, SSLSNISocketConfig func, | 1579 SSL_SNISocketConfigHook(PRFileDesc *fd, SSLSNISocketConfig func, |
1550 void *arg) | 1580 void *arg) |
1551 { | 1581 { |
1552 sslSocket *ss; | 1582 sslSocket *ss; |
1553 | 1583 |
1554 ss = ssl_FindSocket(fd); | 1584 ss = ssl_FindSocket(fd); |
1555 if (!ss) { | 1585 if (!ss) { |
1556 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", | 1586 SSL_DBG(("%d: SSL[%d]: bad socket in SNISocketConfigHook", |
1557 SSL_GETPID(), fd)); | 1587 SSL_GETPID(), fd)); |
1558 return SECFailure; | 1588 return SECFailure; |
1559 } | 1589 } |
1560 | 1590 |
1561 ss->sniSocketConfig = func; | 1591 ss->sniSocketConfig = func; |
1562 ss->sniSocketConfigArg = arg; | 1592 ss->sniSocketConfigArg = arg; |
1563 return SECSuccess; | 1593 return SECSuccess; |
1564 } | 1594 } |
OLD | NEW |