We recently migrated into a new development platform. We are still setting up some parts for our whole workflow to work without issues. We have this one problem where we need to promote a project into Production but we keep getting an error in the server. Our team is not well versed in IronPython to easily resolve this.
I am editing the script concerned regarding this. The original script is as follows: (Please note that I have edited/removed confidential and unnecessary parts)
def callWebService(URI, setProjectState):
job = jobs[0]
job.AddNote(0, job.CurrentVersion, ('%s.' % (job.Id)))
PARAMETERS='{"id": "%s", "someData": "%s"}' % (job.Id, setProjectState)
from System.Net import WebRequest
request = WebRequest.Create(URI)
request.ContentType = "application/json"
request.Method = "POST"
from System.Text import Encoding
bytes = Encoding.ASCII.GetBytes(PARAMETERS)
request.ContentLength = bytes.Length
reqStream = request.GetRequestStream()
reqStream.Write(bytes, 0, bytes.Length)
reqStream.Close()
response = request.GetResponse()
from System.IO import StreamReader
result = StreamReader(response.GetResponseStream()).ReadToEnd()
print result
return;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
callWebService('https://somesite.com/needtoposthere', 'Production')
The new platform's support told us that in order to resolve this, we need to bypass the ssl verification part because it is only in this part of our workflow that we are posting data to an HTTPS url since it's production.
I have tried numerous ways such as adding the ff code:
import ssl
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
Also tried inserting this one as recommended by support:
from System.Net import ServicePointManager
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
and
from System.Net import ServicePointManager
ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072
I've also tried using the verify = false
of the ssl library but still keeps on getting errors.
For the first solution, the error that I'm getting is the ssl
module can't seem to be imported. Logs show the error module named "ssl" cannot be found".
I tried declaring the import like this same as the other import declarations: from System.Net import ssl
but still gets the same error.
For the second solution, the script can't recognize the SecurityProtocolType
even though the ServicePointManager has been imported successfully.
I don't understand why I can't seem to import even Python's built-in libraries (ssl
). Please do understand that the script I've posted is the only one that we can tinker since we do not have access to the other scripts at all.