mirror of
https://github.com/debauchee/barrier.git
synced 2026-11-28 23:05:11 +08:00
Merge remote-tracking branch 'origin/master' into jerry-sandbox
This commit is contained in:
@@ -42,6 +42,10 @@ enum {
|
||||
kMaxRetryCount = 100000
|
||||
};
|
||||
|
||||
enum {
|
||||
kMsgSize = 128
|
||||
};
|
||||
|
||||
static const char kFingerprintDirName[] = "SSL/Fingerprints";
|
||||
//static const char kFingerprintLocalFilename[] = "Local.txt";
|
||||
static const char kFingerprintTrustedServersFilename[] = "TrustedServers.txt";
|
||||
@@ -240,6 +244,10 @@ SecureSocket::initContext(bool server)
|
||||
// load all error messages
|
||||
SSL_load_error_strings();
|
||||
|
||||
if (CLOG->getFilter() >= kINFO) {
|
||||
showSecureLibInfo();
|
||||
}
|
||||
|
||||
// SSLv23_method uses TLSv1, with the ability to fall back to SSLv3
|
||||
if (server) {
|
||||
method = SSLv23_server_method();
|
||||
@@ -298,14 +306,10 @@ SecureSocket::secureAccept(int socket)
|
||||
if (retry == 0) {
|
||||
m_secureReady = true;
|
||||
LOG((CLOG_INFO "accepted secure socket"));
|
||||
const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl);
|
||||
if(cipher != NULL) {
|
||||
char * cipherVersion = SSL_CIPHER_description(cipher, NULL, 0);
|
||||
if(cipherVersion != NULL) {
|
||||
LOG((CLOG_INFO "%s", cipherVersion));
|
||||
OPENSSL_free(cipherVersion);
|
||||
}
|
||||
if (CLOG->getFilter() >= kDEBUG1) {
|
||||
showSecureCipherInfo();
|
||||
}
|
||||
showSecureConnectInfo();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -363,14 +367,10 @@ SecureSocket::secureConnect(int socket)
|
||||
return -1; // Fingerprint failed, error
|
||||
}
|
||||
LOG((CLOG_DEBUG2 "connected secure socket"));
|
||||
const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl);
|
||||
if(cipher != NULL) {
|
||||
char * cipherVersion = SSL_CIPHER_description(cipher, NULL, 0);
|
||||
if(cipherVersion != NULL) {
|
||||
LOG((CLOG_INFO "%s", cipherVersion));
|
||||
OPENSSL_free(cipherVersion);
|
||||
}
|
||||
if (CLOG->getFilter() >= kDEBUG1) {
|
||||
showSecureCipherInfo();
|
||||
}
|
||||
showSecureConnectInfo();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -627,3 +627,72 @@ SecureSocket::serviceAccept(ISocketMultiplexerJob* job,
|
||||
// If status < 0, error happened
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void
|
||||
showCipherStackDesc(STACK_OF(SSL_CIPHER) * stack) {
|
||||
char msg[kMsgSize];
|
||||
int i = 0;
|
||||
for ( ; i < sk_SSL_CIPHER_num(stack) ; i++) {
|
||||
const SSL_CIPHER * cipher = sk_SSL_CIPHER_value(stack,i);
|
||||
|
||||
SSL_CIPHER_description(cipher, msg, kMsgSize);
|
||||
|
||||
// Why does SSL put a newline in the description?
|
||||
int pos = (int)strlen(msg) - 1;
|
||||
if (msg[pos] == '\n') {
|
||||
msg[pos] = '\0';
|
||||
}
|
||||
|
||||
LOG((CLOG_DEBUG1 "%s",msg));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SecureSocket::showSecureCipherInfo()
|
||||
{
|
||||
STACK_OF(SSL_CIPHER) * sStack = SSL_get_ciphers(m_ssl->m_ssl);
|
||||
|
||||
if (sStack == NULL) {
|
||||
LOG((CLOG_DEBUG1 "local cipher list not available"));
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG1 "available local ciphers:"));
|
||||
showCipherStackDesc(sStack);
|
||||
}
|
||||
|
||||
// m_ssl->m_ssl->session->ciphers is not forward compatable, In future release
|
||||
// of OpenSSL, it's not visible, need to use SSL_get_client_ciphers() instead
|
||||
STACK_OF(SSL_CIPHER) * cStack = m_ssl->m_ssl->session->ciphers;
|
||||
if (cStack == NULL) {
|
||||
LOG((CLOG_DEBUG1 "remote cipher list not available"));
|
||||
}
|
||||
else {
|
||||
LOG((CLOG_DEBUG1 "available remote ciphers:"));
|
||||
showCipherStackDesc(cStack);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SecureSocket::showSecureLibInfo()
|
||||
{
|
||||
LOG((CLOG_INFO "%s",SSLeay_version(SSLEAY_VERSION)));
|
||||
LOG((CLOG_DEBUG1 "openSSL : %s",SSLeay_version(SSLEAY_CFLAGS)));
|
||||
LOG((CLOG_DEBUG1 "openSSL : %s",SSLeay_version(SSLEAY_BUILT_ON)));
|
||||
LOG((CLOG_DEBUG1 "openSSL : %s",SSLeay_version(SSLEAY_PLATFORM)));
|
||||
LOG((CLOG_DEBUG1 "%s",SSLeay_version(SSLEAY_DIR)));
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
SecureSocket::showSecureConnectInfo()
|
||||
{
|
||||
const SSL_CIPHER* cipher = SSL_get_current_cipher(m_ssl->m_ssl);
|
||||
|
||||
if (cipher != NULL) {
|
||||
char msg[kMsgSize];
|
||||
SSL_CIPHER_description(cipher, msg, kMsgSize);
|
||||
LOG((CLOG_INFO "%s", msg));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,10 @@ private:
|
||||
serviceAccept(ISocketMultiplexerJob*,
|
||||
bool, bool, bool);
|
||||
|
||||
void showSecureConnectInfo();
|
||||
void showSecureLibInfo();
|
||||
void showSecureCipherInfo();
|
||||
|
||||
private:
|
||||
Ssl* m_ssl;
|
||||
bool m_secureReady;
|
||||
|
||||
@@ -23,6 +23,9 @@
|
||||
#include "base/Log.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
const char * kSynergyVers = VERSION;
|
||||
SecureSocket* g_secureSocket = NULL;
|
||||
@@ -30,8 +33,21 @@ SecureListenSocket* g_secureListenSocket = NULL;
|
||||
Arch* g_arch = NULL;
|
||||
Log* g_log = NULL;
|
||||
|
||||
extern "C" {
|
||||
std::string
|
||||
helperGetLibsUsed(void)
|
||||
{
|
||||
std::stringstream libs(ARCH->getLibsUsed());
|
||||
std::string msg;
|
||||
std::string pid;
|
||||
std::getline(libs,pid);
|
||||
|
||||
while( std::getline(libs,msg) ) {
|
||||
LOG(( CLOG_DEBUG "libs:%s",msg.c_str()));
|
||||
}
|
||||
return pid;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
void
|
||||
init(void* log, void* arch)
|
||||
{
|
||||
@@ -42,6 +58,8 @@ init(void* log, void* arch)
|
||||
if (g_arch == NULL) {
|
||||
Arch::setInstance(reinterpret_cast<Arch*>(arch));
|
||||
}
|
||||
|
||||
LOG(( CLOG_DEBUG "library use: %s",helperGetLibsUsed().c_str()));
|
||||
}
|
||||
|
||||
int
|
||||
@@ -106,4 +124,4 @@ cleanup()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user