2 * Accessor functions for SSLSocket private members.
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
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* $Id: sslreveal.c,v 1.9 2012/04/25 14:50:12 gerv%gerv.net Exp $ */
14 /* given PRFileDesc, returns a copy of certificate associated with the socket
15 * the caller should delete the cert when done with SSL_DestroyCertificate
18 SSL_RevealCert(PRFileDesc
* fd
)
20 CERTCertificate
* cert
= NULL
;
21 sslSocket
* sslsocket
= NULL
;
23 sslsocket
= ssl_FindSocket(fd
);
25 /* CERT_DupCertificate increases reference count and returns pointer to
28 if (sslsocket
&& sslsocket
->sec
.peerCert
)
29 cert
= CERT_DupCertificate(sslsocket
->sec
.peerCert
);
34 /* given PRFileDesc, returns a pointer to PinArg associated with the socket
37 SSL_RevealPinArg(PRFileDesc
* fd
)
39 sslSocket
* sslsocket
= NULL
;
42 sslsocket
= ssl_FindSocket(fd
);
44 /* is pkcs11PinArg part of the sslSocket or sslSecurityInfo ? */
46 PinArg
= sslsocket
->pkcs11PinArg
;
52 /* given PRFileDesc, returns a pointer to the URL associated with the socket
53 * the caller should free url when done
56 SSL_RevealURL(PRFileDesc
* fd
)
58 sslSocket
* sslsocket
= NULL
;
61 sslsocket
= ssl_FindSocket(fd
);
63 if (sslsocket
&& sslsocket
->url
)
64 url
= PL_strdup(sslsocket
->url
);
70 /* given PRFileDesc, returns status information related to extensions
71 * negotiated with peer during the handshake.
75 SSL_HandshakeNegotiatedExtension(PRFileDesc
* socket
,
76 SSLExtensionType extId
,
79 /* some decisions derived from SSL_GetChannelInfo */
80 sslSocket
* sslsocket
= NULL
;
81 SECStatus rv
= SECFailure
;
86 sslsocket
= ssl_FindSocket(socket
);
88 SSL_DBG(("%d: SSL[%d]: bad socket in HandshakeNegotiatedExtension",
89 SSL_GETPID(), socket
));
93 /* according to public API SSL_GetChannelInfo, this doesn't need a lock */
94 if (sslsocket
->opt
.useSecurity
) {
95 if (sslsocket
->ssl3
.initialized
) { /* SSL3 and TLS */
96 /* now we know this socket went through ssl3_InitState() and
97 * ss->xtnData got initialized, which is the only member accessed by
98 * ssl3_ExtensionNegotiated();
99 * Member xtnData appears to get accessed in functions that handle
100 * the handshake (hello messages and extension sending),
101 * therefore the handshake lock should be sufficient.
103 ssl_GetSSL3HandshakeLock(sslsocket
);
104 *pYes
= ssl3_ExtensionNegotiated(sslsocket
, extId
);
105 ssl_ReleaseSSL3HandshakeLock(sslsocket
);