PeculiarVentures / fortify

Fortify enables web applications to use smart cards, local certificate stores and do certificate enrollment. This is the desktop application repository.
https://fortifyapp.com
Other
114 stars 32 forks source link

request client certificate #441

Open thiago-molive opened 2 years ago

thiago-molive commented 2 years ago

how can i request client certificate to authenticate on other api?

I have to use the client's certificate as a way to authenticate in an external api, but i had the message "HTTP request is prohibited with 'Anonymous' client authentication scheme."

i sended PEM from frontend to backend and cast in x509Certificate

rmhrisk commented 2 years ago

Fortify does not implement TLS. You can enroll for a certificate with it but you would use that cert with a TLS implementation.

thiago-molive commented 2 years ago

hi @rmhrisk rmhrisk, thank u for your quickly response.

i'm implement this functionality but i can't use private key of and existing certificate to make handshake on tls. Any idea on how can i use it to comunicate with the api?

I'm currently passing the A1 certificate via fs.readFileSync(path) for test, but I can't use it like that. i want to use all the power of fortifyapp which is a wonderful app.

rmhrisk commented 2 years ago

My guess is you are trying to export the cryptographic key and then use it via a non-webcrypto implementation? If instead you use webcrypto (https://github.com/diafygi/webcrypto-examples) and use the initialized crypto object you will be able to perform the needed operation with an existing key / certificate).

thiago-molive commented 2 years ago

i can do it with public key, my problem is private key, i can't export;

example:

// public key pem in buffer
var selectedCert = this.getMemoryStorage().item(idKey).item;
selectedCert = await n.certStorage.exportCert('raw', certificado);
selectedCert = Buffer.from(an.PemConverter.fromBufferSource(selectedCert , 'CERTIFICATE'));

// private key i'm get with (only for tests)
var key = fs.readFileSync(initPath + '/key.pem');

const agent = new https.Agent({
                        requestCert: true,
                        rejectUnauthorized: false,
                        key: key,
                        cert: selectedCert,
                        passphrase: 'password',
                        ca: ca
                        });

i need change the key and passphrase to use CryptoKey obj and popup password, but I don't know how to do this.

rmhrisk commented 2 years ago

You wont be able to export private keys from tokens, the purpose of the tokens is to keep the private key safe. export goes against that objective. You will need to use handle to the key.

thiago-molive commented 2 years ago

hello Ryan, I've been trying to implement this for some time and I'm short on deadline. Do you provide commercial support to develop this functionality?

my contact: thiago.zeyu@gmail.com

rmhrisk commented 2 years ago

If you can use WebCrypto with a non-extractable key it should work with Fortify fine; if you can verify your code works with WebCrypto non-exportable keys the change to use Fortify is trivial no need for a support contract.

thiago-molive commented 2 years ago

so can you help me? For isn't easy to do that

rmhrisk commented 2 years ago

What I recommend is creating the smallest example of using a pre-existing webcrypto key you can and then graft that into your larger example.