From fdff42dd9e3c37af5d3662a5a33fca15231de64e Mon Sep 17 00:00:00 2001 From: michael Date: Wed, 9 Jan 2019 10:22:28 +0000 Subject: [PATCH] * Soem simplification and reformatting git-svn-id: trunk@40814 - --- packages/gnutls/examples/privkey.pp | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/packages/gnutls/examples/privkey.pp b/packages/gnutls/examples/privkey.pp index d82c3141ca..e3e94d886b 100644 --- a/packages/gnutls/examples/privkey.pp +++ b/packages/gnutls/examples/privkey.pp @@ -33,24 +33,18 @@ var begin LoadGnuTLS; Assert(GnuTLSLoaded); + key:=nil; try - try - TLSCheckRet(gnutls_x509_privkey_init(@key)); - priv_key_size := gnutls_sec_param_to_pk_bits(GNUTLS_PK_RSA, - GNUTLS_SEC_PARAM_HIGH); - SetLength(priv_key, Pred(priv_key_size)); - TLSCheckRet(gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, - priv_key_size, 0)); - TLSCheckRet(gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, - @priv_key[1], @priv_key_size)); - SetLength(priv_key, Pred(priv_key_size)); - - WriteLn(priv_key); - except - gnutls_x509_privkey_deinit(key); - raise; - end; + TLSCheckRet(gnutls_x509_privkey_init(@key)); + priv_key_size := gnutls_sec_param_to_pk_bits(GNUTLS_PK_RSA,GNUTLS_SEC_PARAM_HIGH); + SetLength(priv_key, Pred(priv_key_size)); + TLSCheckRet(gnutls_x509_privkey_generate(key, GNUTLS_PK_RSA, priv_key_size, 0)); + TLSCheckRet(gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, @priv_key[1], @priv_key_size)); + SetLength(priv_key, Pred(priv_key_size)); + WriteLn(priv_key); finally + if key<>Nil then + gnutls_x509_privkey_deinit(key); FreeGnuTLS; end; end.