Authentification using .pem certificate #88
-
Hello guys. I need to hit api that requires cert authentification using key and certificate (.pem) and passphrase. |
Beta Was this translation helpful? Give feedback.
Answered by
Sammyjo20
Oct 13, 2022
Replies: 1 comment 1 reply
-
You should use the Using Authenticatorsclass ServiceAuthenticator implements AuthenticatorInterface
{
/**
* @param string $certificatePath
* @param string|null $certificatePassword
* @param string|null $username
* @param bool|null $testing
*/
public function __construct(
public string $certificatePath,
public ?string $certificatePassword = null,
) {
//
}
/**
* Apply the certificate configuration.
*
* @param SaloonRequest $request
* @return void
* @throws \ReflectionException
* @throws \Sammyjo20\Saloon\Exceptions\SaloonInvalidConnectorException
*/
public function set(SaloonRequest $request): void
{
$request->addConfig('cert', [$this->certificatePath, $this->certificatePassword]);
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Sammyjo20
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should use the
cert
Guzzle option in thedefaultConfig
array on the connector or if you have a different certificate I would recommend using an authenticator that adds the option.Using Authenticators