<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fabric notebook connection to API that requires mTLS authentication in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624329#M8195</link>
    <description>&lt;P&gt;Theoretically a Key Vault secret is only [Redacted] if you try to print() it*.&amp;nbsp; You should be able to use it 'as is'.&lt;BR /&gt;How are you getting from certificate to cert?&amp;nbsp; Is cert an actual path in your output?&amp;nbsp; Can you print the path?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the link below, the cert parameter appears to need to be a tuple of the certificate path and the key path.&lt;BR /&gt;&lt;A href="https://www.pythonrequests.com/python-requests-library-mtls/#:~:text=How%20to%20use%20Python%20Requests%20library%20for%20mTLS,the%20requests.request%28%29%20method.%20Here%27s%20an%20example%3A%20print%20%28response.content%29" target="_blank"&gt;python requests library mtls&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;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?&amp;nbsp; (I've not seen methods of just adding the cert to a loaded string)&lt;BR /&gt;&lt;BR /&gt;* I'm not going to speculate about any bypass methods.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Mar 2025 14:16:36 GMT</pubDate>
    <dc:creator>spencer_sa</dc:creator>
    <dc:date>2025-03-25T14:16:36Z</dc:date>
    <item>
      <title>Fabric notebook connection to API that requires mTLS authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624063#M8193</link>
      <description>&lt;P&gt;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:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;certificate = mssparkutils.credentials.getSecret('https://&amp;lt;name&amp;gt;.vault.azure.net/', 'certification-name')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, when I perform a GET request like this:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;requests.get('https://api.endpoint.com/example', headers=headers, cert=cert)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;OSError: Could not find the TLS certificate file, invalid path: [REDACTED]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I solve this?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem is that this certificate value is redacted:&amp;nbsp;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook#secret-redaction" target="_blank"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/author-execute-notebook#secret-redaction&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 11:48:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624063#M8193</guid>
      <dc:creator>arlindTrystar</dc:creator>
      <dc:date>2025-03-25T11:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric notebook connection to API that requires mTLS authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624329#M8195</link>
      <description>&lt;P&gt;Theoretically a Key Vault secret is only [Redacted] if you try to print() it*.&amp;nbsp; You should be able to use it 'as is'.&lt;BR /&gt;How are you getting from certificate to cert?&amp;nbsp; Is cert an actual path in your output?&amp;nbsp; Can you print the path?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From the link below, the cert parameter appears to need to be a tuple of the certificate path and the key path.&lt;BR /&gt;&lt;A href="https://www.pythonrequests.com/python-requests-library-mtls/#:~:text=How%20to%20use%20Python%20Requests%20library%20for%20mTLS,the%20requests.request%28%29%20method.%20Here%27s%20an%20example%3A%20print%20%28response.content%29" target="_blank"&gt;python requests library mtls&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;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?&amp;nbsp; (I've not seen methods of just adding the cert to a loaded string)&lt;BR /&gt;&lt;BR /&gt;* I'm not going to speculate about any bypass methods.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 14:16:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624329#M8195</guid>
      <dc:creator>spencer_sa</dc:creator>
      <dc:date>2025-03-25T14:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fabric notebook connection to API that requires mTLS authentication</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624381#M8196</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;But yes, for anyone interested, you should write the certificate to a temporary file and then pass it to requests library. Something like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;with tempfile.NamedTemporaryFile(delete=False) as cert_file:
            cert_file.write(certificate.encode())
            cert_file.flush()
            cert_path = cert_file.name&lt;/LI-CODE&gt;&lt;P&gt;where 'certificate' is the certificate content, and the cert_file is the temporary file path, and then you pass cert_file to requests library&lt;/P&gt;</description>
      <pubDate>Tue, 25 Mar 2025 15:00:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Fabric-notebook-connection-to-API-that-requires-mTLS/m-p/4624381#M8196</guid>
      <dc:creator>arlindTrystar</dc:creator>
      <dc:date>2025-03-25T15:00:28Z</dc:date>
    </item>
  </channel>
</rss>

