Skip to content

Reading private key from file seems to be not working due to hex encryption #30

@gpaolopedrazza

Description

@gpaolopedrazza

Hi,
the login_pk procedure calls the Oracle BFILENAME function passing the directory where the private key is stored and the filename of the private key as arguments and reads the content of the file using the DBMS_LOB package.

l_bfile := bfilename( i_path, i_file );
dbms_lob.fileopen( l_bfile );
l_private_key := dbms_lob.substr( l_bfile, 32767, 1 );
dbms_lob.fileclose( l_bfile );

I tried with my private key, but the value I have got for the l_private_key variable is hex encoded.
That leads the parse_private_key function to fail because is designed to work with plain text and not with hex code.
Th hextoraw function fails also due to max string length exceeded.
I tried to replace the code with something like

l_file := UTL_FILE.fopen ('MY_DIR', 'id_rsa', 'R');
LOOP
BEGIN
UTL_FILE.get_line (l_file, l_read);
DBMS_OUTPUT.put_line (l_read);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
EXIT;
END;
END LOOP;

and ssh login worked.
Probably there is something I do not considering, but I do not see why with need to handle the private key file that way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions