mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 04:35:46 +01:00
- Added ssl_get_peer_cert() to SSL API
This commit is contained in:
parent
d2c167e9a8
commit
b0550d90c9
@ -928,6 +928,22 @@ const char *ssl_get_ciphersuite( const ssl_context *ssl );
|
|||||||
*/
|
*/
|
||||||
const char *ssl_get_version( const ssl_context *ssl );
|
const char *ssl_get_version( const ssl_context *ssl );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return the peer certificate from the current connection
|
||||||
|
*
|
||||||
|
* Note: Can be NULL in case no certificate was sent during
|
||||||
|
* the handshake. Different calls for the same connection can
|
||||||
|
* return the same or different pointers for the same
|
||||||
|
* certificate and even a different certificate altogether.
|
||||||
|
* The peer cert CAN change in a single connection if
|
||||||
|
* renegotiation is performed.
|
||||||
|
*
|
||||||
|
* \param ssl SSL context
|
||||||
|
*
|
||||||
|
* \return the current peer certificate
|
||||||
|
*/
|
||||||
|
const x509_cert *ssl_get_peer_cert( const ssl_context *ssl );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Perform the SSL handshake
|
* \brief Perform the SSL handshake
|
||||||
*
|
*
|
||||||
|
@ -3405,6 +3405,14 @@ const char *ssl_get_version( const ssl_context *ssl )
|
|||||||
return( "unknown" );
|
return( "unknown" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const x509_cert *ssl_get_peer_cert( const ssl_context *ssl )
|
||||||
|
{
|
||||||
|
if( ssl == NULL || ssl->session == NULL )
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return ssl->session->peer_cert;
|
||||||
|
}
|
||||||
|
|
||||||
const int ssl_default_ciphersuites[] =
|
const int ssl_default_ciphersuites[] =
|
||||||
{
|
{
|
||||||
#if defined(POLARSSL_DHM_C)
|
#if defined(POLARSSL_DHM_C)
|
||||||
|
@ -539,7 +539,7 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
printf( " . Peer certificate information ...\n" );
|
printf( " . Peer certificate information ...\n" );
|
||||||
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
||||||
ssl.session->peer_cert );
|
ssl_get_peer_cert( &ssl ) );
|
||||||
printf( "%s\n", buf );
|
printf( "%s\n", buf );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -172,7 +172,7 @@ int do_handshake( ssl_context *ssl, struct options *opt )
|
|||||||
|
|
||||||
printf( " . Peer certificate information ...\n" );
|
printf( " . Peer certificate information ...\n" );
|
||||||
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
||||||
ssl->session->peer_cert );
|
ssl_get_peer_cert( &ssl ) );
|
||||||
printf( "%s\n", buf );
|
printf( "%s\n", buf );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
|
@ -501,7 +501,7 @@ reset:
|
|||||||
{
|
{
|
||||||
printf( " failed\n" );
|
printf( " failed\n" );
|
||||||
|
|
||||||
if( !ssl.session->peer_cert )
|
if( !ssl_get_peer_cert( &ssl ) )
|
||||||
printf( " ! no client certificate sent\n" );
|
printf( " ! no client certificate sent\n" );
|
||||||
|
|
||||||
if( ( ret & BADCERT_EXPIRED ) != 0 )
|
if( ( ret & BADCERT_EXPIRED ) != 0 )
|
||||||
@ -518,11 +518,11 @@ reset:
|
|||||||
else
|
else
|
||||||
printf( " ok\n" );
|
printf( " ok\n" );
|
||||||
|
|
||||||
if( ssl.session->peer_cert )
|
if( ssl_get_peer_cert( &ssl ) )
|
||||||
{
|
{
|
||||||
printf( " . Peer certificate information ...\n" );
|
printf( " . Peer certificate information ...\n" );
|
||||||
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
x509parse_cert_info( (char *) buf, sizeof( buf ) - 1, " ",
|
||||||
ssl.session->peer_cert );
|
ssl_get_peer_cert( &ssl ) );
|
||||||
printf( "%s\n", buf );
|
printf( "%s\n", buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user