mirror of
				https://github.com/cuberite/polarssl.git
				synced 2025-11-03 20:22:59 -05:00 
			
		
		
		
	Implement saving peer cert as part of session.
This commit is contained in:
		
							parent
							
								
									aaa1eab55a
								
							
						
					
					
						commit
						5f280cc6cf
					
				@ -3224,6 +3224,7 @@ const x509_cert *ssl_get_peer_cert( const ssl_context *ssl )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
int ssl_get_session( const ssl_context *ssl, ssl_session *dst )
 | 
					int ssl_get_session( const ssl_context *ssl, ssl_session *dst )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					    int ret;
 | 
				
			||||||
    ssl_session *src;
 | 
					    ssl_session *src;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if( ssl == NULL ||
 | 
					    if( ssl == NULL ||
 | 
				
			||||||
@ -3239,10 +3240,23 @@ int ssl_get_session( const ssl_context *ssl, ssl_session *dst )
 | 
				
			|||||||
    ssl_session_free( dst );
 | 
					    ssl_session_free( dst );
 | 
				
			||||||
    memcpy( dst, src, sizeof( ssl_session ) );
 | 
					    memcpy( dst, src, sizeof( ssl_session ) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /*
 | 
					#if defined(POLARSSL_X509_PARSE_C)
 | 
				
			||||||
     * For now, just set peer_cert to NULL, deep-copy not implemented yet
 | 
					    if( src->peer_cert != NULL )
 | 
				
			||||||
     */
 | 
					    {
 | 
				
			||||||
    dst->peer_cert = NULL;
 | 
					        if( ( dst->peer_cert = polarssl_malloc( sizeof(x509_cert) ) ) == NULL )
 | 
				
			||||||
 | 
					            return( POLARSSL_ERR_SSL_MALLOC_FAILED );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        memset( dst->peer_cert, 0, sizeof(x509_cert) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if( ( ret = x509parse_crt( dst->peer_cert, src->peer_cert->raw.p,
 | 
				
			||||||
 | 
					                                   src->peer_cert->raw.len ) != 0 ) )
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            polarssl_free( dst->peer_cert );
 | 
				
			||||||
 | 
					            dst->peer_cert = NULL;
 | 
				
			||||||
 | 
					            return( ret );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					#endif /* POLARSSL_X509_PARSE_C */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return( 0 );
 | 
					    return( 0 );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user