473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Python SSL Socket Client to Java SSL Server. HELP me PLEASE.

Hi,
I want to make simple client in phyton, which would be able to communicate
with Java server using SSL sockets.
There is the Java clients, which is doing this - so I'm pretty sure, that
Java server works OK.

I've heard, that P2.3 has SSL support included in himself and also, I was
trying P2.2 with pyOpenSSL wrappers and extensions, but unsuccesfuly...

So, could you give me a few lines of python code which makes such things:
1. Importing nessesary libraries,
2. Connects to specified server and port with SSL socket (no cert.
validation is needed - just using server cert. to encrypt transmission),
3. Sends some string to server (something like command "GET_VER"),
4. Reads answer from server (it could be something similar to Java
Object... - Java strings, arrays of bytes, etc),
5. Prints this answer in human readable manner in console,
6. Disconnect from server.

It would be nice, if this code will use only opensource or freeavailable
soft/libs and Python 2.2 or 2.3.

--
Greetings from Poland,
Krzysztof Paź.
Jul 18 '05 #1
1 5414
On the Java server side I'm using ObjectInput/OutputStream classes to
provide efficient communication.

After accepting incoming connection, SSL handshake is done properly - I
think.

Next, while server is creating streams for reading and writing data with
client I've got such exception in Java Server Code - during call of code:
JavaCode: datain = new ObjectInputStream(client.getInputStream
()); - where client is client socket,
JavaException: java.io.StreamCorruptedException: invalid stream header
at
java.io.ObjectInputStream.readStreamHeader(ObjectI nputStream.java:737)
at java.io.ObjectInputStream.<init>(ObjectInputStream .java:253)
....
So, what is the problem ?

If there is any possibility to read/write data with SSLsockets from Python
to Java ObjectInput/Output Streams or not ?

Any ideas ?

Kris.

PS.
Main part of my test python client code:
===
def verify_cb(conn, cert, errnum, depth, ok):
print 'Got certificate: %s' % cert.get_subject()
return ok

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ctx = SSL.Context(SSL.SSLv3_METHOD)
ctx.set_verify(SSL.VERIFY_NONE, verify_cb)
ss = SSL.Connection(ctx,s)
print 'Python socket client. Connecting to: ', `HOST`, `PORT`, '.'
ss.connect((HOST, PORT))
print 'Writing query to server...'
ss.send("GET_VER")
print 'Reading response from server...'
data = ss.recv(2048)
s.close()
print 'Received', `data`
===
this code make such output:
===
Python socket client. Connecting to: [my server...].
Writing query to server...
Got certificate: <...[cert data - ok]...>
Reading response from server...
Traceback (most recent call last):
File "D:\Install\Python\conn.py", line 24, in ?
data = ss.recv(2048)
SSL.ZeroReturnError
===
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Al Wilkerson | last post by:
Is anyone aware of any special things to remember when sending Objects back in forth between Client and Sever, other than every readObject() should have a writeObject() and vice versa ? Does the...
11
by: Nick Keighley | last post by:
I'm probably missing something rather obvious, but is there a known problem with getting a Python based socket program to communicate with a C based socket program? A simple echo server written in...
13
by: Ajay | last post by:
hi! can you call a Python application from a Java program? does this require any additional package to be installed? thanks cheers
4
by: zbcong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting for a...
2
by: zhebincong | last post by:
Hello: I write a multithread c# socket server,it is a winform application,there is a richtextbox control and button,when the button is click,the server begin to listen the socket port,waiting...
2
by: happyvalley | last post by:
Hi, don't know if it is the place to ask this question I have a c++ server and a java client communicate via socket in Java client // create a client socket Socket clientSocket = new...
3
by: madsornomads | last post by:
Hi all, I have a problem with reading from a Java server after I have written to it - it just hangs. It works fine if I just write to the server and not try to write. I have read the HOWTO on...
0
by: kuguy | last post by:
Hi all, I'm new to the forums, so I hope this isn't in the wrong place... I have that "Software caused connection abort: socket write error" exception error that i've never meet before. ...
3
by: TsanChung | last post by:
I want to make a java TCP socket client to communicate with a TCP server socket on linux. Are there some sample C unix server and java client socket programs available? The Richard Stevens'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.