From 2bbfb6262cafdd28cffa3e0523867917eaad48e0 Mon Sep 17 00:00:00 2001 From: ddraganov Date: Fri, 5 Apr 2024 13:34:54 +0300 Subject: [PATCH] Add certFile and certKeyFile to SoapStubAdapter SoapStubAdapter uses the schemeArgs dictionary to pass HTTPConnection and HTTPSConnection parameters around. However, with the planned Python 3.12 changes, some parameters will no longer be supported. This changes adds certFile and certKeyFile as SoapStubAdapter class attributes and updates the current consumers. --- pyVim/connect.py | 12 +++++++----- pyVmomi/SoapAdapter.py | 2 ++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pyVim/connect.py b/pyVim/connect.py index f7bee3e9..06090407 100644 --- a/pyVim/connect.py +++ b/pyVim/connect.py @@ -1,5 +1,7 @@ ############################################################# -# Copyright (c) 2005-2024 VMware, Inc. All rights reserved. +# Copyright (c) 2005-2024 Broadcom. All Rights Reserved. +# The term "Broadcom" refers to Broadcom Inc. +# and/or its subsidiaries. ############################################################# # @file connect.py @@ -132,8 +134,8 @@ def makeCertHokTokenLoginMethod(stsUrl, stsCert=None, ssl_context=None): def _doLogin(soapStub): from . import sso - cert = soapStub.schemeArgs['cert_file'] - key = soapStub.schemeArgs['key_file'] + cert = soapStub.certFile + key = soapStub.certKeyFile authenticator = sso.SsoAuthenticator(sts_url=stsUrl, sts_cert=stsCert) @@ -177,8 +179,8 @@ def makeCredBearerTokenLoginMethod(username, def _doLogin(soapStub): from . import sso - cert = soapStub.schemeArgs['cert_file'] - key = soapStub.schemeArgs['key_file'] + cert = soapStub.certFile + key = soapStub.certKeyFile authenticator = sso.SsoAuthenticator(sts_url=stsUrl, sts_cert=stsCert) samlAssertion = authenticator.get_bearer_saml_assertion( diff --git a/pyVmomi/SoapAdapter.py b/pyVmomi/SoapAdapter.py index 292b3af8..0738e3ee 100644 --- a/pyVmomi/SoapAdapter.py +++ b/pyVmomi/SoapAdapter.py @@ -1478,6 +1478,8 @@ def __init__(self, self.pool = [] self.connectionPoolTimeout = connectionPoolTimeout self.lock = threading.Lock() + self.certFile = certFile + self.certKeyFile = certKeyFile self.schemeArgs = {} if sslContext: self.schemeArgs['context'] = sslContext