Skip to content

Conversation

danmastrowtrusstai
Copy link

@danmastrowtrusstai danmastrowtrusstai commented May 7, 2025

Without this change you're unable to connect to MyPureCloud APIs
@danmastrowtrusstai
Copy link
Author

def patched_create_mtls_or_ssl_context(self):
    if self.ssl_context is None:
        ssl_context = ssl.create_default_context(purpose=ssl.Purpose.SERVER_AUTH)

        if self.ssl_ca_cert:
            ssl_context.load_verify_locations(cafile=self.ssl_ca_cert)
        else:
            # If no CA certs are provided, use certifi's bundle.
            try:
                ssl_context.load_verify_locations(cafile=certifi.where())
            except ImportError:
                pass

        if self.cert_file and self.key_file:
            # mTLS configuration
            ssl_context.load_cert_chain(certfile=self.cert_file, keyfile=self.key_file)

        self.ssl_context = ssl_context

# Bind the patched method to the configuration instance
PureCloudPlatformClientV2.configuration.create_mtls_or_ssl_context = types.MethodType(
    patched_create_mtls_or_ssl_context, PureCloudPlatformClientV2.configuration
)

Workaround to patch the import in the meantime

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant