[jwt] proper memory ownership for RSA key components

This patch corrects the ownership for RSA key's module and exponent in
RSAJWTPublicKeyBuilder::ConvertJwkToPem() for OpenSSL versions prior
to 1.1.0.  Prior to this patch, jwt-util-test would crash with SIGSEGV
if compiled and run against earlier OpenSSL versions (e.g. 1.0.1)

*** SIGSEGV (@0x1e800002) received by PID 31969 (TID 0x7f07a0ae5940) from PID 511705090; stack trace: ***
    ...
    @       0x3ae366ad5d CRYPTO_free at ??:0
    @       0x3ae36a6ef5 BN_free at ??:0
    @     0x7f07a9a44d85 std::_Function_handler<>::_M_invoke() at ??:0
    @     0x7f07a9a4571d std::function<>::operator()() at ??:0
    @     0x7f07a99f42ac std::unique_ptr<>::~unique_ptr() at ??:0
    @     0x7f07a99e6cfa kudu::RSAJWTPublicKeyBuilder::ConvertJwkToPem() at ??:0
    @     0x7f07a99e5910 kudu::RSAJWTPublicKeyBuilder::CreateJWKPublicKey() at ??:0
    ...

Change-Id: Ib94122eb7221c99ed4997b456cdcea4cd6d5154b
Reviewed-on: http://gerrit.cloudera.org:8080/19292
Tested-by: Kudu Jenkins
Reviewed-by: Zoltan Chovan <zchovan@cloudera.com>
Reviewed-by: Attila Bukor <abukor@apache.org>
1 file changed