Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #9499 from sepalani/pcap-ssl-raw
PCAP: Add raw SSL packets logging support
  • Loading branch information
leoetlino committed Feb 14, 2021
2 parents efab17c + d3dd830 commit f79e629
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Source/Core/Core/IOS/Network/SSL.cpp
Expand Up @@ -20,6 +20,7 @@
#include "Core/Core.h"
#include "Core/HW/Memmap.h"
#include "Core/IOS/Network/Socket.h"
#include "Core/PowerPC/PowerPC.h"

namespace IOS::HLE
{
Expand Down Expand Up @@ -54,17 +55,30 @@ namespace
int SSLSendWithoutSNI(void* ctx, const unsigned char* buf, size_t len)
{
auto* ssl = static_cast<WII_SSL*>(ctx);
auto* fd = &ssl->hostfd;

if (ssl->ctx.state == MBEDTLS_SSL_SERVER_HELLO)
mbedtls_ssl_set_hostname(&ssl->ctx, ssl->hostname.c_str());
return mbedtls_net_send(&ssl->hostfd, buf, len);
const int ret = mbedtls_net_send(fd, buf, len);

// Log raw SSL packets if we don't dump unencrypted SSL writes
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE) && ret > 0)
PowerPC::debug_interface.NetworkLogger()->LogWrite(buf, ret, *fd, nullptr);

return ret;
}

int SSLRecv(void* ctx, unsigned char* buf, size_t len)
{
auto* ssl = static_cast<WII_SSL*>(ctx);
auto* fd = &ssl->hostfd;
const int ret = mbedtls_net_recv(fd, buf, len);

// Log raw SSL packets if we don't dump unencrypted SSL reads
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ) && ret > 0)
PowerPC::debug_interface.NetworkLogger()->LogRead(buf, ret, *fd, nullptr);

return mbedtls_net_recv(&ssl->hostfd, buf, len);
return ret;
}
} // namespace

Expand Down

0 comments on commit f79e629

Please sign in to comment.