Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I need to connect to an API that requires mTLS authentication. I have stored the certificate in Azure Key Vault, and I can retrieve it this way:
certificate = mssparkutils.credentials.getSecret('https://<name>.vault.azure.net/', 'certification-name')
So, when I perform a GET request like this:
requests.get('https://api.endpoint.com/example', headers=headers, cert=cert)
I get this error:
OSError: Could not find the TLS certificate file, invalid path: [REDACTED]
How can I solve this?
The problem is that this certificate value is redacted: https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook#secret-redaction
Solved! Go to Solution.
Theoretically a Key Vault secret is only [Redacted] if you try to print() it*. You should be able to use it 'as is'.
How are you getting from certificate to cert? Is cert an actual path in your output? Can you print the path?
From the link below, the cert parameter appears to need to be a tuple of the certificate path and the key path.
python requests library mtls
If you're storing the cert / key in the key vault you may need to write these to a temporary file location for the requests to pick them up? (I've not seen methods of just adding the cert to a loaded string)
* I'm not going to speculate about any bypass methods.
Thank you for your response. Yes, for now it looks like the only option is to write the certificate content to a temporary file location and then pass that file location to the requests library.
However, now the client_secret and client_id that I get from azure key vault are 'REDACTED' and when I pass them to the requests library, it does not work. This is what I'm researching for now.
But yes, for anyone interested, you should write the certificate to a temporary file and then pass it to requests library. Something like this:
with tempfile.NamedTemporaryFile(delete=False) as cert_file:
cert_file.write(certificate.encode())
cert_file.flush()
cert_path = cert_file.name
where 'certificate' is the certificate content, and the cert_file is the temporary file path, and then you pass cert_file to requests library
Theoretically a Key Vault secret is only [Redacted] if you try to print() it*. You should be able to use it 'as is'.
How are you getting from certificate to cert? Is cert an actual path in your output? Can you print the path?
From the link below, the cert parameter appears to need to be a tuple of the certificate path and the key path.
python requests library mtls
If you're storing the cert / key in the key vault you may need to write these to a temporary file location for the requests to pick them up? (I've not seen methods of just adding the cert to a loaded string)
* I'm not going to speculate about any bypass methods.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Fabric update to learn about new features.
User | Count |
---|---|
14 | |
5 | |
4 | |
3 | |
2 |
User | Count |
---|---|
32 | |
8 | |
7 | |
3 | |
3 |