Can't connect to JIRA Python through REST api https url - python

I try to connect to a jira dev sandbox through https but it comes up with an SSL23_GET_SERVER_HELLO:unknown protocol error
This is the error log/stack trace. I try both ports 8080 and 443 but no joy.
>>> from jira.client import JIRA
>>> options = {'server':'localhost:8080'}
>>> auth = ('username', 'password')
>>> jira = JIRA(options, auth)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__
self._create_http_basic_session(*basic_auth)
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session
r = self._session.post(url, data=json.dumps(payload))
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post
return self.request('post', url, data=data, **kwargs)
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/home/ve/lib/python2.6/site-packages/requests/models.py", line 638, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 1] _ssl.c:480: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
>>> options = {'server':'localhost:443'}
>>> auth = ('username', 'password')
>>> jira = JIRA(options, auth)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 88, in __init__
self._create_http_basic_session(*basic_auth)
File "/home/ve/lib/python2.6/site-packages/jira/client.py", line 1369, in _create_http_basic_session
r = self._session.post(url, data=json.dumps(payload))
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 284, in post
return self.request('post', url, data=data, **kwargs)
File "/home/ve/lib/python2.6/site-packages/requests/sessions.py", line 241, in request
r.send(prefetch=prefetch)
File "/home/ve/lib/python2.6/site-packages/requests/models.py", line 631, in send
raise ConnectionError(sockerr)
requests.exceptions.ConnectionError: [Errno 110] Connection timed out
>>>

Try this:
from jira.client import JIRA
options = {'server':'localhost:8080'}
jira = JIRA(options)
jira = JIRA(basic_auth=('username', 'password'))
If it doesn't help, any chance the have OpenSSL conflicts?
When curl is linked against OpenSSL 0.9.8 and tries to access a server running OpenSSL 1.0.0, the SSL handshake fails with:
curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

Got it now. Port 8080 was set up and was not a defauld for http connection whether as for https I used validation manipulation basically setting validate = False in the jira-python method body

Related

SSL problems using Twilio

I'm trying to use Twilio to send SMS. I'm using their templates to send my first test message:
import os
from twilio.rest import Client
client = Client(my_SID, my_TOKEN)
message = client.messages \
.create(
body="Join Earth's mightiest heroes. Like Kevin Bacon.",
from_= number1,
to= number2
)
print(message.sid)
I've manually replaced the SID and the TOKEN with their respective values as per Twilio's console (the os.environ[] function doesn't work). The thing is, this error appearas as I try to run the code:
PS C:\Users\USER> & C:/Users/USER/anaconda3/python.exe "d:/Escritorio/amigo secreto/send_sms.py"
Traceback (most recent call last):
File "C:\Users\USER\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 688, in urlopen
conn = self._get_conn(timeout=pool_timeout)
File "C:\Users\USER\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 280, in _get_conn
return conn or self._new_conn()
File "C:\Users\USER\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 979, in _new_conn
raise SSLError(
urllib3.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\USER\anaconda3\lib\site-packages\requests\adapters.py", line 439, in send
resp = conn.urlopen(
File "C:\Users\USER\anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755, in urlopen
retries = retries.increment(
File "C:\Users\USER\anaconda3\lib\site-packages\urllib3\util\retry.py", line 574, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='api.twilio.com', port=443): Max retries exceeded with url: /2010-04-01/Accounts/ACfd9e165c0a6ba1760d5671ccbfc5dbc6/Messages.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:/Escritorio/amigo secreto/send_sms.py", line 10, in <module>
message = client.messages \
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\rest\api\v2010\account\message\__init__.py", line 88, in create
payload = self._version.create(method='POST', uri=self._uri, data=data, )
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\base\version.py", line 193, in create
response = self.request(
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\base\version.py", line 39, in request
return self.domain.request(
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\base\domain.py", line 38, in request
return self.twilio.request(
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\rest\__init__.py", line 131, in request
return self.http_client.request(
File "C:\Users\USER\anaconda3\lib\site-packages\twilio\http\http_client.py", line 91, in request
response = session.send(
File "C:\Users\USER\anaconda3\lib\site-packages\requests\sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "C:\Users\USER\anaconda3\lib\site-packages\requests\adapters.py", line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.twilio.com', port=443): Max retries exceeded with url: /2010-04-01/Accounts/ACfd9e165c0a6ba1760d5671ccbfc5dbc6/Messages.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
I've never used an API before, I could really use somebody's guidance. Thanks in advance
Twilio developer evangelist here.
That error looks as though you have issues between your installation of Anaconda and the SSL module. There's a potential fix from this GitHub issue, run:
execstack -c anaconda3/lib/libcrypto.so.1.0.0
Alternatively, other comments suggest installing OpenSSL for your environment.

How to collect files on Windows machines with pywinrm?

How to collect files on Windows machines?
Password rejected on pywinrm connection, but the password is correct and the connection port is listening
Script:
import winrm
s = winrm.Session('192.168.9.102', auth=('domain\username', 'password'))
r = s.run_cmd('ipconfig', ['/all'])
print(r.status_code)
print(r.std_out)
Output:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/winrm/transport.py", line 329, in _send_message_request
response.raise_for_status()
File "/usr/local/lib/python3.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: for url: http://192.168.9.102:5985/wsman
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "get.py", line 4, in <module>
r = s.run_cmd('ipconfig', ['/all'])
File "/usr/local/lib/python3.7/site-packages/winrm/__init__.py", line 39, in run_cmd
shell_id = self.protocol.open_shell()
File "/usr/local/lib/python3.7/site-packages/winrm/protocol.py", line 166, in open_shell
res = self.send_message(xmltodict.unparse(req))
File "/usr/local/lib/python3.7/site-packages/winrm/protocol.py", line 243, in send_message
resp = self.transport.send_message(message)
File "/usr/local/lib/python3.7/site-packages/winrm/transport.py", line 323, in send_message
response = self._send_message_request(prepared_request, message)
File "/usr/local/lib/python3.7/site-packages/winrm/transport.py", line 333, in _send_message_request
raise InvalidCredentialsError("the specified credentials were rejected by the server")
winrm.exceptions.InvalidCredentialsError: the specified credentials were rejected by the server
telnet 192.168.9.102 5985
Trying 192.168.9.102...
Connected to 192.168.9.102.
Escape character is '^]'.
^CConnection closed by foreign host.
Have you tried using another authentication transport like ntlm, according to your server configuration:
winrm.Session('192.168.9.102', auth=('username#domain', 'password'), transport='ntlm')

python SOAP with zeep, requests.exception: 403 client error

I'm trying to make a SOAP client in python using zeepSo far I've had zero luck in trying to get it to run. I keep getting the following error.
Traceback (most recent call last):
File "C:/Users/z905/PycharmProjects/Soap_Test/soap_test.py", line 14, in <module>
client = Client(wsdl=client_location, transport=transport_with_basic_auth)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\client.py", line 134, in __init__
self.wsdl = Document(wsdl, self.transport, strict=strict)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\wsdl\wsdl.py", line 81, in __init__
root_definitions = Definition(self, document, self.location)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\wsdl\wsdl.py", line 178, in __init__
self.parse_imports(doc)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\wsdl\wsdl.py", line 270, in parse_imports
document = self.wsdl._get_xml_document(location)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\wsdl\wsdl.py", line 140, in _get_xml_document
location, self.transport, self.location, strict=self.strict)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\loader.py", line 72, in load_external
content = transport.load(url)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\transports.py", line 110, in load
content = self._load_remote_data(url)
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\zeep\transports.py", line 126, in _load_remote_data
response.raise_for_status()
File "C:\Users\z905\PycharmProjects\Soap_Test\venv\lib\site-packages\requests\models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden (Forbidden port) for url: http://url:7104
I've tried the program with and without basic authentication.
from zeep import Client
from requests import Session
from requests.auth import HTTPBasicAuth
from zeep.transports import Transport
client_location = "file://C:/<path-to-local-file>"
loc = "<url-to-wsdl>"
session = Session()
session.auth = HTTPBasicAuth('usrname', 'pass')
transport_with_basic_auth = Transport(session=session)
client = Client(wsdl=client_location, transport=transport_with_basic_auth)
And version without Basic Auth.
from zeep import Client
from zeep.wsse.username import UsernameToken
client_location = "file://C:/<path-to-local-file>"
loc = "<url-to-wsdl>"
client = Client(wsdl=loc, wsse=UsernameToken(usr, password, use_digest=True))
I was able to solve the issue by doing the following. The issue was caused by some firewall issues and the proxy not working.
import requests
session = requests.session()
session.trust_env = False
transport = Transport(session=session)
client = Client(wsdl=client_location, wsse=UsernameToken(usr, password, use_digest=True), transport=transport)

Fetching an jira issue using python i'm getting authentication error

>>> # Get all projects viewable by anonymous users.
... projects = jira.projects()
Traceback (most recent call last):
File "<stdin>", line 2, in <module>
File "C:\Python27\lib\site-packages\jira_python-0.16-py2.7.egg\jira\client.py", line 941, in projects
r_json = self._get_json('project')
File "C:\Python27\lib\site-packages\jira_python-0.16-py2.7.egg\jira\client.py", line 1526, in _get_json
r = self._session.get(url, params=params, headers=self._options['headers'])
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests-2.2.1-py2.7.egg\requests\adapters.py", line 381, in send
raise ProxyError(e)
**requests.exceptions.ProxyError: Cannot connect to proxy. Socket error: Tunnel connection failed: 407 authenticationrequired.**
Can you please any one help me how to solve this issue.
Try This:
basic_auth = ('username', 'password')
options = {
'server': <server url>,
'proxies' : <proxy>,
'verify' : False,
}
jira = JIRA(options,basic_auth=basic_auth,validate=True)
should work.
I tried and it is working for me.
Make sure you have access to the project to acess the issue.

HTTPS proxies with Requests: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol

I am using Requests 1.2.3 on Windows 7 x64 and am trying to connect to (any) site via HTTPS using a HTTPS proxy by passing the proxies argument to the request.
I don't experience this error when using urllib2's ProxyHandler, so I don't think it's on my proxy's side.
>>> opener = urllib2.build_opener(urllib2.ProxyHandler({'https': 'IP:PORT'}))
>>> resp = opener.open('https://www.google.com')
>>> resp.url
'https://www.google.co.uk/'
>>> resp = requests.get('https://www.google.com', proxies={'https': 'IP:PORT'})
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\requests\api.py", line 55, in get
return request('get', url, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 335, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 438, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 331, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
I should probably note that the same error still happens if I pass verify=False to the request.
Any suggestions? I've looked at related questions but there was nothing that worked for me.
I suspect your proxy is a http proxy over which you can use https (the common case)
The problem is, that requests uses https to talk to proxies if the request itself https.
Using an explicit protocol (http) for your proxy should fix things: proxies={'https': 'http://IP:PORT'}
Also have a look at https://github.com/kennethreitz/requests/issues/1182

Categories

Resources