1

I just had my computer re-imaged and have Python 2.7.9 (64-bit) installed on my machine. Using PIP I have beatbox 32.1 installed.

When I make the call to connect to Salesforce:

sf_client.login(sf_username, sf_password)
logging.info('Connected successfully')

I receive an error message. I have tried just the normal login credentials which has always worked and have attempted to connect with my token in the password too. Has anyone run into this error with Python Beatbox and do you know what debugging options I could try to get to the bottom of this?

Traceback (most recent call last):
File "C:\myCode\salesforceload_beatbox.py", line 126, in <module>
sf_client.login(sf_username, sf_password)
File "C:\Python27\lib\site-packages\beatbox\python_client.py", line 76, in login
res = BaseClient.login(self, username, passwd)
File "C:\Python27\lib\site-packages\beatbox\_beatbox.py", line 62, in login
lr = LoginRequest(self.serverUrl, username, password).post()
File "C:\Python27\lib\site-packages\beatbox\_beatbox.py", line 330, in post
raise RuntimeError('No response from Salesforce')
RuntimeError: No response from Salesforce

After digging deeper into this (and debugging the HTTP connection with requests package), I'm failing at this level

Traceback (most recent call last):
File "C:\myCode\SFDC\test_beatbox_call2.py", line 34, in <module>
requests.get(sf_client.login(sf_username, sf_password))
File "C:\Python27\lib\site-packages\beatbox\python_client.py", line 76, in login
res = BaseClient.login(self, username, passwd)
File "C:\Python27\lib\site-packages\beatbox\_beatbox.py", line 78, in login
lr = LoginRequest(self.serverUrl, username, password).post()
File "C:\Python27\lib\site-packages\beatbox\_beatbox.py", line 344, in post
conn.request("POST", path, self.makeEnvelope(), headers)
File "C:\Python27\lib\httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 1035, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 997, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 850, in _send_output
self.send(msg)
File "C:\Python27\lib\httplib.py", line 812, in send
self.connect()
File "C:\Python27\lib\httplib.py", line 1216, in connect
server_hostname=server_hostname)
File "C:\Python27\lib\ssl.py", line 350, in wrap_socket
_context=self)
File "C:\Python27\lib\ssl.py", line 566, in __init__
self.do_handshake()
File "C:\Python27\lib\ssl.py", line 788, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
Steve I
  • 21
  • 5
  • The fact that your HTTP request is failing at the handshake makes me think it has something to do with sending the request rather than anything regarding salesforce. Are you able to send any http requests elsewhere? What if you simply created a GET request to google.com. Does that work? You should be able to do this straight from the REPL. type this: import urllib2 urllib2.urlopen("https://google.com").read() #python 2.x – ZAR Mar 04 '15 at 22:17
  • That seems to work fine. I added this logic to it to confirm that I receive data back: value = urllib2.urlopen("https://www.google.com/").read() #python 2.x print value Huge response block comes back with the google doodle and other google related – Steve I Mar 05 '15 at 16:32
  • So I attempted to embed the call above into a requests.get call to get more of a stack trace and I see this: File "C:\Python27\lib\site-packages\requests\models.py", line 341, in prepare_url url = url.decode('utf8') File "C:\Python27\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 14515: invalid start byte – Steve I Mar 05 '15 at 16:34
  • That seems to be a different issue. Can you post your request code above? That seems to be a problem encoding one of your characters, maybe a password element that isn't UTF-8? – ZAR Mar 05 '15 at 16:56
  • Seems like a red herring as I'm able to get the response easily from google.com. And on the python to salesforce call, both my username and password just have numbers and letters. Have tried multiple logins which all work on another machine. I even spun up a new VM and installed the packages exactly as I did on my local machine and that works fine. Do you know if Salesforce could be looking for an SSL cert on my newly re-imaged machine that could be a mismatch from prior to me doing the re-image or something? – Steve I Mar 05 '15 at 20:55
  • Considering that you are able to handshake with other services, the certificate issue you described could be it. Although I don't believe that would cause an error as much as a warning that the certificate couldn't be verified. Plus, you're able to navigate to SF and login from a browser yea? The problem is more likely in your python library. Maybe try reinstalling python. Also, why not open up the SSL.py script and see what's happening at line 788. – ZAR Mar 06 '15 at 03:48
  • Correct, no issues with salesforce through browser. Here is the method within the ssl.py file: – Steve I Mar 06 '15 at 14:29
  • def do_handshake(self, block=False): """Perform a TLS/SSL handshake.""" self._check_connected() timeout = self.gettimeout() try: if timeout == 0.0 and block: self.settimeout(None) self._sslobj.do_handshake() finally: self.settimeout(timeout) if self.context.check_hostname: if not self.server_hostname: raise ValueError("check_hostname needs server_hostname " "argument") match_hostname(self.getpeercert(), self.server_hostname) – Steve I Mar 06 '15 at 14:29
  • Check this thread out: http://stackoverflow.com/questions/25835554/ssl-certificate-verification-failure-in-python-on-mavericks – ZAR Mar 06 '15 at 15:49
  • Specifically: " printing ssl.OPENSSL_VERSION from python3 revealed that it was using 0.9.7, whereas the same command from python2 was 0.9.8. Installing the 64-bit up'ed the OpenSSL version to 0.9.8. Thanks for the help everyone! I hope this is useful for others" from the OP on that thread. The issue seemed to be that he installed a 32 bit version rather than 64 – ZAR Mar 06 '15 at 15:50
  • That thread makes sense and I have actually installed both 32-bit and 64-bit. The latest one I have been using since starting this thread is here: https://www.python.org/downloads/windows/ (Python 2.7.9 - 2014-12-10; Windows x86-64 MSI installer) What is really interesting on that other thread are the comments on PIP and an older version of that. Reason I'm saying that is when I was debugging the SSL areas, my debug statements only hit when doing the install, not running the actual py code. So I'm wondering if the root of my issue is at the installation level from PIP – Steve I Mar 06 '15 at 19:10
  • Perhaps. Why not try a reinstall? – ZAR Mar 06 '15 at 19:11
  • I've done that at every level. Beatbox within PIP, PIP itself, different bit versions of Python. Even followed the exact same setup steps on other vms I spun up exactly the same, can only recreate it on my machine regardless of the level of reinstall. – Steve I Mar 06 '15 at 23:06
  • Steve man, OS issues are out of my scope. I have no idea how to proceed here. Sorry – ZAR Mar 06 '15 at 23:12
  • Appreciate you trying, i'm in the same boat! – Steve I Mar 07 '15 at 03:28
  • Well, I believe I may have figured this out. Wanted to post my findings from this weekend that resolved this issue. Will add it to a resolution comment below. – Steve I Mar 09 '15 at 21:29

1 Answers1

1

After searching and googling profusely about TLS connections, etc, I noticed this weekend that my cmd.exe window (which I run the PIP commands from) was launching under C:\Windows\System32> and all of my vms were launching within my personal user directory. So I searched for my roaming cmd.exe and when I opened that, it was to my personal user directory. After doing an uninstall and install of beatbox using PIP in the new cmd.exe, all of my Salesforce calls via Beatbox work like they used to. Now I can't fully explain why this is the case, but something tells me that the certs for this admin location are probably mismatched to my personal certificates. I'm up and running again.

Steve I
  • 21
  • 5