OpenSSH Private Key

kmu123 6 Reputation points
2021-02-18T22:03:41.497+00:00

How to open an OpenSSH private key file and read its content data to a buffer? There is no private key file extension. is there any way to verify that the selected file is a private key file? I am using the following method. But I am not sure that if there is any other method to open the private key file and read its contents? Thank you for your help in advance.
char * buffer;
long size;
ifstream file ("C:\Test\keyfile", ios::in|ios::binary|ios::ate);
if(file) {
size = file.tellg();
file.seekg (0, ios::beg);
buffer = new char [size];
file.read (buffer, size); file.close();
}
cout << "the complete file is in a buffer";
delete[] buffer;

Developer technologies | C++
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.