Hallo,
I'm trying to read the PEM public key from a memory BIO with the
following code. It's Delphi, but I think the meaning is clear:
=====
procedure TJSEVPKey.GetPublicKeyPEM(jsni: TiJavaScriptNativeInterface);
const
bufLen = 2048;
var
bio: Pointer;
buf: Pointer;
len: Integer;
pos: Integer;
Result: String;
begin
GetMem(buf, bufLen);
bio := BIO_new(BIO_s_mem());
try
EVPCheck(PEM_write_bio_PUBKEY(bio, FKey));
// reading from the buffer with the PEM
pos := 1;
Result := '';
repeat
len := BIO_read(bio, buf, bufLen);
if len = -1 then
begin
if BIO_should_retry(bio) = 0 then
RaiseEVPError
end
else if len > 0 then
begin
SetLength(Result, Length(Result) + len);
Move(buf, Result[pos], len);
pos := pos + len;
end
until len = 0;
finally
BIO_vfree(bio);
FreeMem(buf)
end;
jsni.setResult(Result)
end;
=====
The problem is BIO_read keeps returning -1 and BIO_should_retry
keeps returning non-zero forever, so I'm stuck in an endless loop.
What may be causing this?
Thanks,
--
-alex
http://www.ventonegro.org/
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [email protected]
Automated List Manager [EMAIL PROTECTED]