Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ssl python client server and verification

    Greetings
    Currently I am working on a prototype just for my personal uses of a 2 step authentication
    I am in need of writing it in python because it will be an add on to a program that is written in python as well.
    What needs to happen is I have 2 clients (these are mockups)
    1 desktop client
    1 phone client
    1 server

    The server will be listening on an SSL data socket on some port say 55576 (doesn't matter) it needs to handle multiple ssl connections at a time

    The desktop client will open up and then try to make a secure connection to the server, It then sends a "verification" message which the server checks to see if this is actually the desktop. This can be hardcoded
    The 2nd client is then initiated the (phone) and it makes a SSL connection also and a verification message also.

    Currently what I have running is a multi thread server with a desktop and "phone" and a server but it is not in SSL because I do not know how to encapsulate all of it. Along with I don't have any verification.

    Can someone help me with the SSL certs and encapsulation and the verification?
    honestly not that good at programming


    Here is a mock up of a verification process that I want to implement into the server but I dont know where to add it nor how to get it to function 100% because within the client when it connects it should automatically send 1 message that is hardcoded into it that would be "client1desktop or client2mobile" and based on the first message it would check to see if it matches if it doesn't it disconnects

    How would i edit the code in the client to autosend a specified message and after the server checks how do i get out of the loop of the authentication/verification just so you can continue on
    [code]

    (intromessage would be the first message the client sends but this would be done automatically )

    auth = intromessage
    if auth == client1desktop:
    print "Client Desktop Accepted"
    elif auth == client2mobile:
    print "Client Mobile Accepted"
    else:
    print "No valid client detected"
    print "Good bye!"
    (force discconect from server)
    [code]



    Here is the code for the server
    Code:
    from socket import *
    import thread, ssl
     
    def handler(clientsocket, clientaddr):
        print "Accepted connection from: ", clientaddr
     
        while 1:
            data = clientsocket.recv(1024)
            if not data:
                break
            else:
                print data
                msg = "You sent me: %s" % data
                clientsocket.send(msg)
        clientsocket.close()
     
    if __name__ == "__main__":
     
        host = 'localhost'
        port = 55567
        buf = 1024
     
        addr = (host, port)
     
        serversocket = socket(AF_INET, SOCK_STREAM)
     
        serversocket.bind(addr)
     
        serversocket.listen(2)
     
        while 1:
            print "Server is listening for connections\n"
            
             
            clientsocket, clientaddr = serversocket.accept()
          
            thread.start_new_thread(handler, (clientsocket, clientaddr))
        serversocket.close()

    Here is the code for the client (they are both the exact same)
    Code:
    from socket import *
     
    if __name__ == '__main__':
     
        host = 'localhost'
        port = 55567
        buf = 1024
     
        addr = (host, port)
     
        clientsocket = socket(AF_INET, SOCK_STREAM)
     
        clientsocket.connect(addr)
     
        while 1:
            data = raw_input(">> ")
            if not data:
                break
            else:
                clientsocket.send(data)
                data = clientsocket.recv(buf)
                if not data:
                    break
                else:
                    print data
        clientsocket.close()

    Also see diagram which may help in understanding what I need help with

    ------------------------
    Deleted by eenookami, 500 points refunded - Sat Jul 12 2014 07:21:17 GMT+0930 (CST)

  • #2
    New to the CF scene
    Join Date
    Jul 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    whoops forgot the attachment

    Also why can't i edit my own post?
    Attached Thumbnails Attached Thumbnails ssl python client server and verification-prot.jpg  


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •