MCPcopy Create free account
hub / github.com/ByConity/ByConity / generateRSAKeys

Method generateRSAKeys

src/Server/MySQLHandlerFactory.cpp:100–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98}
99
100void MySQLHandlerFactory::generateRSAKeys()
101{
102 LOG_TRACE(log, "Generating new RSA key pair.");
103 public_key.reset(RSA_new());
104 if (!public_key)
105 throw Exception("Failed to allocate RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
106
107 BIGNUM * e = BN_new();
108 if (!e)
109 throw Exception("Failed to allocate BIGNUM. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
110 SCOPE_EXIT(BN_free(e));
111
112 if (!BN_set_word(e, 65537) || !RSA_generate_key_ex(public_key.get(), 2048, e, nullptr))
113 throw Exception("Failed to generate RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
114
115 private_key.reset(RSAPrivateKey_dup(public_key.get()));
116 if (!private_key)
117 throw Exception("Failed to copy RSA key. Error: " + getOpenSSLErrors(), ErrorCodes::OPENSSL_ERROR);
118}
119#endif
120
121Poco::Net::TCPServerConnection * MySQLHandlerFactory::createConnection(const Poco::Net::StreamSocket & socket, TCPServer & tcp_server)

Callers

nothing calls this directly

Calls 4

getOpenSSLErrorsFunction · 0.85
ExceptionClass · 0.50
resetMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected