sassoftware / saspy

A Python interface module to the SAS System. It works with Linux, Windows, and Mainframe SAS as well as with SAS in Viya.
https://sassoftware.github.io/saspy
Other
373 stars 150 forks source link

Unable to connect to zOS due to lack of encryption #373

Closed juler69 closed 3 years ago

juler69 commented 3 years ago

I am using Anaconda with Python 3.8 trying to connect to SAS on zOS which is running SAS Connect.

I installed saspy and created a personal configuration file with the following: ` SAS_config_names=['myIOM'] SAS_config_options = {'lock_down': False, 'verbose' : True }

SAS_output_options = {'output' : 'html5'} myIOM = {'java' : '/usr/bin/java', 'authkey' : 'myIOM', 'iomhost' : 'example.com', 'iomport' : 15327, 'autoexec' : 'options filesystem=hfs;' } ` I have a authinfo file with the authkey and my userid and password in it.

I downloaded the encryption jars from our zOS install of SAS and copied them to the saspy/java/iomclient folder as per the instructions I read somewhere. I have tried letting it pick them up automatically which it seems to do and I have tried using the classpath method which also picks them up.

My issue is that the SAS spawner on the mainframe requires encryption but is logging that the client (me) is requesting cleartext and thus refuses my connection.

Spawner logs: clientNegotiate: server = 0x0 <App.Connect.Spawner.Client> clientNegotiate: encryption available= 0 <App.Connect.Spawner.Client> clientNegotiate: encryption required = 0 <App.Connect.Spawner.Client> clientNegotiate: encryption keySize = <App.Connect.Spawner.Client> clientNegotiate: checking to see if client supports SAS encryption <App.Connect.Spawner.Client> writeClientMsg: Enter, sending buffer of length 3. <App.Connect.Spawner.Client.Comm> writeBuf: Enter, writing 3 bytes. <App.Connect.Spawner.Client.Comm> writeBuf: Exit, error=0. <App.Connect.Spawner.Client.Comm> writeClientMsg: Exit, error=0. <App.Connect.Spawner.Client.Comm> readBuf: Enter, reading 3 bytes from socket 0x40fd2ae0. <App.Connect.Spawner.Client.Comm> readBytes: Enter, buffer 3 bytes long. <App.Connect.Spawner.Client.Comm> readBytes: dataReady returned status=0 (0x0) with a byteCnt of 201 and error=2 (0x2). <App.Connect.Spawner.Client.Comm> readBytes: tcpRead returned status=0 (0x0) with a len of 3. <App.Connect.Spawner.Client.Comm> readBytes: Exit, read 3 bytes. <App.Connect.Spawner.Client.Comm> readBuf: readBytes returned 3 bytes. <App.Connect.Spawner.Client.Comm> readBuf: Exit, error=0. <App.Connect.Spawner.Client.Comm> clientNegotiate: client responded with 49 02 00 <App.Connect.Spawner.Client> clientNegotiate: clear text requested <App.Connect.Spawner.Client> Client connection 0x1 communicating without encryption but connections from clients that do not support encryption are not allowed. Refer to the CLEARTEXT option. <App.Connect.Spawner.Client>.

My python script is simply doing: import saspy sas = saspy.SASsession()

python logs: `Using SAS Config named: myIOM We failed in getConnection This release of IOM Bridge for Java does not understand the command sent by the peer: -1.

SAS process has terminated unexpectedly. Pid State= (59187, 64000) SAS Connection failed. No connection established. Double check your settings in sascfg_personal.py file.

Attempted to run program /usr/bin/java with the following parameters:['/usr/bin/java', '-classpath', '/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/saspyiom.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.svc.connection.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/log4j.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.security.sspi.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.core.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.rutil.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.rutil.nls.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sastpj.rutil.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.rutil.zos.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sas.rutil.zos.nls.jar:/opt/anaconda3/pkgs/saspy-3.3.6-py_0/site-packages/saspy/java/iomclient/sastpj.rutil.zos.jar', 'pyiom.saspy2j', '-host', 'localhost', '-stdinport', '57261', '-stdoutport', '57262', '-stderrport', '57263', '-iomhost', 'example.com', '-iomport', '15327', '-user', 'a123456', '-lrecl', '1048576', '']

No SAS process attached. SAS process has terminated unexpectedly. Invalid response from SAS on inital submission. printing the SASLOG as diagnostic

Traceback (most recent call last):

File "", line 1, in saspy.SASsession()

File "/opt/anaconda3/lib/python3.8/site-packages/saspy/sasbase.py", line 537, in init self.pyenc = sas_encoding_mapping[self.sascei]

KeyError: 'No SAS process attached. SAS process has terminated unexpectedly.' `

Running Python 3.8 under Anaconda on MacBook Pro

tomweber-sas commented 3 years ago

Hey @juler69, Looks like you set up everything correctly, good job with that. The trouble is that saspy doesn't connect to SAS/Connect (not SAS/Share for that matter), but rather to a Workspace server. It connects to an Object Spawner that's configured to start Workspace servers (and others perhaps), and that's the IOM protocol saspy uses to get a SAS session (only a Workspace server), not Connect. Do you have a Workspace server configured on your MVS system? Or only SAS/Connect?

juler69 commented 3 years ago

That'd be why then. We only have SAS Connect so I guess this is off the table for now. Thanks for the reply.

tomweber-sas commented 3 years ago

yeah, sorry about that :(