how do we import prikey file for the PKCS#8 format?
https://github.com/CESNET/libnetconf2/blob/a7c8a81988adc9e1be7491788a67b71542a06116/src/session_server_ssh.c#L69
how do we import prikey file for the PKCS#8 format? for examples
PKCS#5 plain private key
-----BEGIN RSA PRIVATE KEY-----
MIIBOwIBAAJBANxtmQ1Kccdp7HBNt8zgTai48Vv617bj4SnhkcMN99sCQ2Naj/sp
... (snip) ...
NiCYNLiCawBbpZnYw/ztPVACK4EwOpUy+u19cMB0JA==
-----END RSA PRIVATE KEY-----
PKCS#8 plain private key
-----BEGIN PRIVATE KEY-----
MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEA6GZN0rQFKRIVaPOz
... (snip) ...
LaLGdd9G63kLg85eldSy55uIAXsvqQIgfSYaliVtSbAgyx1Yfs3hJ+CTpNKzTNv/
Fx80EltYV6k=
-----END PRIVATE KEY-----
Hi, you have not mentioned much details and I am not sure why you referenced the line you did but if you want to use such keys in libnetconf2, all you should need to do is return the path to the hostkey callback. You have an option to return raw data (which are then processed by the function and the tags added) or directly the path to the PEM file.
Regards, Michal
following,
/* write the key into the file */
written = fwrite("-----BEGIN ", 1, 11, file);
written += fwrite(key_str, 1, strlen(key_str), file);
written += fwrite(" PRIVATE KEY-----\n", 1, 18, file);
written += fwrite(in, 1, strlen(in), file);
written += fwrite("\n-----END ", 1, 10, file);
written += fwrite(key_str, 1, strlen(key_str), file);
written += fwrite(" PRIVATE KEY-----", 1, 17, file);
if the key file is written in PKCS#8 format, there is not RSA, DSA, EC word in the first line, it seems like "-----BEGIN PRIVATE KEY-----" not "-----BEGIN RSA PRIVATE KEY-----".
Hi, what I replied is true even though you ignored it and you could have used this key if provided in a file rather than data. However, I suppose there is no reason for it not to be supported when returned as raw data so now it should be.
Regards, Michal