| 524 | |
| 525 | #if USE_SSH |
| 526 | void Connection::performHandshakeForSSHAuth() |
| 527 | { |
| 528 | String challenge; |
| 529 | { |
| 530 | writeVarUInt(Protocol::Client::SSHChallengeRequest, *out); |
| 531 | out->next(); |
| 532 | UInt64 packet_type = 0; |
| 533 | if (in->eof()) |
| 534 | throw Poco::Net::NetException("Connection reset by peer"); |
| 535 | |
| 536 | readVarUInt(packet_type, *in); |
| 537 | if (packet_type == Protocol::Server::SSHChallenge) |
| 538 | { |
| 539 | readStringBinary(challenge, *in); |
| 540 | } |
| 541 | else if (packet_type == Protocol::Server::Exception) |
| 542 | receiveException()->rethrow(); |
| 543 | else |
| 544 | throwUnexpectedPacket(packet_type, "SSHChallenge or Exception"); |
| 545 | } |
| 546 | |
| 547 | writeVarUInt(Protocol::Client::SSHChallengeResponse, *out); |
| 548 | |
| 549 | auto pack_string_for_ssh_sign = [&](String challenge_) |
| 550 | { |
| 551 | String message; |
| 552 | message.append(std::to_string(DBMS_TCP_PROTOCOL_VERSION)); |
| 553 | message.append(default_database); |
| 554 | message.append(user); |
| 555 | message.append(challenge_); |
| 556 | return message; |
| 557 | }; |
| 558 | |
| 559 | String to_sign = pack_string_for_ssh_sign(challenge); |
| 560 | String signature = ssh_private_key.signString(to_sign); |
| 561 | writeStringBinary(signature, *out); |
| 562 | out->next(); |
| 563 | } |
| 564 | #endif |
| 565 | |
| 566 |
nothing calls this directly
no test coverage detected