I'm setting certificate auth to my nifi server.
I have used nifi-tools/tls-toolkit from nifi project to generate a keystore, truststore, client certificate and so on.
I have added the client certificate generated by tls-toolkit in p12 format to my browser and configured my nifi server property. All works fine.
Now I want to use the client certificate within ruby script.
To do that I have converted the certificate from p12 format to pem format like that...
openssl pkcs12 -in CN=admin_DC=nifi_DC=com.p12 -passin pass:26V+Hs1qupglToDlVqO+oKW0yWR2jG3uXjuFTUus76o -out a.pem
MAC verified OK
Enter PEM pass phrase:
PEM pass phrase in blank.
To test it I tried
curl --insecure --cert-type pem --cert "a.pem" "https://127.0.0.1:9443/nifi"
curl: (35) error reading X.509 key or certificate file: Error in parsing.
Error in parsing? I haven't found any info about it.
Let's to verify...
openssl verify a.pem
a.pem: DC = com, DC = nifi, CN = admin
error 20 at 0 depth lookup:unable to get local issuer certificate
Verify with tha CA file...
openssl verify -verbose -x509_strict -issuer_checks -CAfile nifi-cert.pem a.pem
a.pem: OK
With my ruby script fails too (obviously)
require 'rest_client'
a = RestClient::Resource.new(
'https://127.0.0.1:9443/nifi',
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read("a.pem")),
:verify_ssl => OpenSSL::SSL::VERIFY_NONE
).get
pp a
`
I get...
/usr/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=unknown state: sslv3 alert bad certificate (OpenSSL::SSL::SSLError)
from /usr/lib/ruby/2.3.0/net/http.rb:933:in `connect'
from /usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
from /usr/lib/ruby/2.3.0/net/http.rb:852:in `start'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:715:in `transmit'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:145:in `execute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/request.rb:52:in `execute'
from /var/lib/gems/2.3.0/gems/rest-client-2.0.2/lib/restclient/resource.rb:51:in `get'
from test.rb:8:in `<main>'
Whats wrong?
Thanks.