Skip to content

Instantly share code, notes, and snippets.

@azuisleet
Last active October 6, 2019 21:27
Show Gist options
  • Save azuisleet/e2859ac9f88e1c6dee028e591ed0dc72 to your computer and use it in GitHub Desktop.
Save azuisleet/e2859ac9f88e1c6dee028e591ed0dc72 to your computer and use it in GitHub Desktop.
STEAMNETWORKINGSOCKETS_INTERFACE bool GameNetworkingSockets_InitWithCert(int appId, const SteamNetworkingIdentity* pIdentity, void* privateKey, void *cert, int certLen, SteamNetworkingErrMsg& errMsg)
{
SteamDatagramTransportLock lock;
// Init basic functionality
if (!g_SteamNetworkingSocketsUser.BInitGameNetworkingSockets(pIdentity, errMsg))
{
g_SteamNetworkingSocketsUser.Kill();
return false;
}
g_SteamNetworkingSocketsUser.m_nAppID = appId;
g_SteamNetworkingSocketsUser.m_keyPrivateKey.SetRawDataAndWipeInput(privateKey, 32);
g_SteamNetworkingSocketsUser.m_msgSignedCert.ParseFromArray(cert, certLen);
g_SteamNetworkingSocketsUser.m_msgCert.ParseFromString(g_SteamNetworkingSocketsUser.m_msgSignedCert.cert());
// Sanity check:
CECSigningPublicKey pubKey;
if (!pubKey.SetRawDataWithoutWipingInput(g_SteamNetworkingSocketsUser.m_msgCert.key_data().c_str(), g_SteamNetworkingSocketsUser.m_msgCert.key_data().length()))
{
return false;
}
if (!g_SteamNetworkingSocketsUser.m_keyPrivateKey.MatchesPublicKey(pubKey))
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment