0

I am attempting to connect to a remote server which requires mutual auth. I have received a .p12 file from the server, and used the following commands to generate my private key and client cert:

openssl pkcs12 -in my_dev.p12 -out clientCert.crt -nokeys -clcerts
openssl pkcs12 -in my_dev.p12  -nocerts -nodes -passin pass:mypassword | openssl rsa -out privkey.pem

And I have used the following code to setup a Manticore Client :

client = Manticore::Client.new(
    pool_max: 200,
    pool_max_per_route: 200,
    ssl: { verify: :disable, client_key: client_key , client_cert: client_cert })

url = "https://my_url.com"
resp = client.get(url).call

The response I am getting is this:

401 Unauthorized
Unauthorized
This server could not verify that you\nare authorized to access the document
requested.  Either you supplied the wrong
credentials (e.g., bad password), or your
browser doesn't understand how to supply
the credentials required.

I am very new to using mutual auth, and am not sure exactly where I am going wrong. Have I extracted the clientCert and privateKey correctly ? Am I suppling the key and cert to Manticore correctly ?

4

1 回答 1

1

ssl[:keystore]您可以通过以下选项直接从 Manticore 使用 PKCS12 文件:

client = Manticore::Client.new(
  pool_max: 200,
  pool_max_per_route: 200,
  ssl: { keystore: "/path/to/auth.p12", keystore_password: "your_password" }
)

keystore用于您希望提供给远程服务器的证书,而truststore用于您希望用于验证远程服务器身份的公共证书;您可能不应该verify: :disable在这种情况下使用,因为您确实想验证连接另一端的身份。

于 2015-08-04T17:27:27.247 回答