I've installed component suit from overbyteics 8.16 in XE8 Delphi (Rad Studio).
When i want to open a p12 file in developer computer, it loads, but when application runs on Windows Server 2012 R2 raises "\r\nError on opening file \"c:\\Files\\certif\\clientkstore.p12\"\r\nerror:02001005:system library:fopen:Input\/output error\r\nerror:2006D002:BIO routines:BIO_new_file:system lib\r\n" message.
Development pc has openssl64 installed. W2012 R2 server: not.
c:\Files folder has high permissions for application users, for reading and writing.
The error is raised from OverbyteIcsWSocket unit:
2procedure myprocedure(myKey: string; var X: PPKC512; var Y: PX509);
var path: string;
FileBio : PBIO;
PKey : PEVP_PKEY;
ca: PSTACK;
begin
path := 'c:\Files\certif\clientkstore.p12'; // read from ini or register
InitializeSsl;
FileBio := OpenFileBio(path, bomRead); //<-- here raises. See next function down
try
if not Assigned(FileBio) then
raise EX509Exception.Create('BIO not assigned');
X := f_d2i_PKCS12_bio(FileBio, nil);
if not Assigned(X) then
RaiseLastOpenSslError(EX509Exception, TRUE,
'Error reading certificate from BIO PKC512');
try
if IncludePrivateKey then begin
f_BIO_ctrl(FileBio, BIO_CTRL_RESET, 0, nil);
PKey := f_PEM_read_bio_PrivateKey(FileBio, nil, nil,
PAnsiChar(AnsiString(Password)));
if not Assigned(PKey) then
RaiseLastOpenSslError(EX509Exception, TRUE,
'Error reading private key from BIO');
try
X509 := X;
PrivateKey := PKey;
finally
f_EVP_PKEY_free(PKey);
end;
end else
P12 := X;
f_PKCS12_parse(P12, myKey, PKey, Y, ca);
X509 := Y;
finally
f_PKCS12_free(X);
end;
finally
f_bio_free(FileBio);
end;
end;
//........................................................................................//
function TX509Base.OpenFileBio(
const FileName : String;
Methode : TBioOpenMethode): PBIO;
begin
if (Filename = '') then
raise EX509Exception.Create('File name not specified');
if (Methode = bomRead) and (not FileExists(Filename)) then
raise EX509Exception.Create('File not found "' +
Filename + '"');
if Methode = bomRead then
Result := f_BIO_new_file(PAnsiChar(AnsiString(Filename)), PAnsiChar('r+')) //<------ here raises
else
Result := f_BIO_new_file(PAnsiChar(AnsiString(Filename)), PAnsiChar('w+'));
if (Result = nil) then
RaiseLastOpenSslError(EX509Exception, TRUE,
'Error on opening file "' + Filename + '"');
end;
ssleay32.dll and libeay32.dll are in same folder than app.
How can solve it?