Hi Dave, I've tried my code again and I get the following error:
330098688:error:0D07A097:asn1 encoding routines:ASN1_mbstring_ncopy:string too long:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/asn1/a_mbstr.c:154:maxsize=64 4330098688:error:0B07806F:x509 certificate routines:X509_PUBKEY_set:unsupported algorithm:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/asn1/x_pubkey.c:219: 4330098688:error:0B07806F:x509 certificate routines:X509_PUBKEY_set:unsupported algorithm:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/crypto/asn1/x_pubkey.c:219: This is why my call PEM_write fails. My DH is generating a key of 2048 bits. Is this a problem? Any clue how can I fix it. About other questions on the Java side, what we're doing is re-write a client that's currently written in Java to C++ to improve performance and reduce memory footprint because this will be embedded in a small device. So what we should do is send the same data as the Java client, because is the data that the server understands. Aleix Ventayol | Mobile Jazz C. Nàpols, 187, 9º, 08013 Barcelona http://mobilejazz.cat<http://www.google.com/url?q=http%3A%2F%2Fmobilejazz.cat%2F&sa=D&sntz=1&usg=AFrqEzfgZdKlXETCdfdRKpZ-ieYGYbSPXA> On Wed, Jun 19, 2013 at 4:28 AM, Dave Thompson <dthomp...@prinpay.com>wrote: > >From: owner-openssl-us...@openssl.org On Behalf Of Aleix Ventayol > >Sent: Tuesday, 18 June, 2013 17:33 > > >I've tried it using the following code: > > EVP_PKEY * pp = EVP_PKEY_new(); > > EVP_PKEY_set1_DH(pp, dh); > > char *buff; > > BUF_MEM *bptr; > > int write_rc = 0; > > BIO *bmem = BIO_new(BIO_s_mem()); > > write_rc = PEM_write_bio_PUBKEY(bmem, pp); > > >But I'm not getting anything in pp and write_rc is 0. > > Works for me, using file-BIO instead (easier to test). > Are you sure dh contains a valid key? What's in the error > queue? Easiest way is ERR_print_errors_fp(stderr) . > > <snip> > > ______________________________________________________________________ > OpenSSL Project http://www.openssl.org > User Support Mailing List openssl-users@openssl.org > Automated List Manager majord...@openssl.org >