0
votes

A project uses OverByteICS components, in RadStudio XE8 Delphi, and... when I create a TX509 Component for access a P12 certificate, and load from file, the TX509Base.OpenFileBio function in OberbyteIcsWSocket unit 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" exception message...

The server where app runs hasn't openSSl installed. But that is the idea, to use this component for not install openSSL.... The libeay32.dll and ssleay32.dll are in same folder as the app. What could be happening?

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
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;

and its caller

procedure TPKCS12Certificate.LoadFromP12File(const FileName: String;
  IncludePrivateKey: Boolean; const Password: String);
var
    FileBio : PBIO;
    X     : PPKCS12;//PX509;
    Y     : PX509;
    PKey  : PEVP_PKEY;
    ca: PSTACK;
begin
  InitializeSsl;
  FileBio := OpenFileBio(FileName, bomRead); {<-- Here raises}
  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;
    X509 := Y;
    finally
         f_PKCS12_free(X);
    end;
    finally
        f_bio_free(FileBio);
    end;
end;
1
Your question is not clear. It looks more an OpenSSL question that and ICS question. Which ICS version, which OpenSSL version ? Which OpenSSL binaries ? Please provide complete simple and reproductible sample program. Overbyte ICS support is done there: en.delphipraxis.net/forum/37-ics-internet-component-suite Better to post there if you want best answer.fpiette
Isn´t clear?... doesn´t load the certificate for encrypt, more clear: water. Thanx I must go to overbyte supportNizamUlMulk

1 Answers

0
votes

Solved with last version of ICS Components