This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SSL communication
#1
Hello,
My LogicMachine communicates with second device via TCP (outgoing from LogicMachine) and HTTP (incoming to LogicMachine) protocols , I want to secure them with SSL. I can ensure SSL certificate with JavaScript in second device.




When I create socket it runs this code:

 
  local host, port = "IP address", portNO.
  local socket = require("socket")
  local tcp = assert(socket.tcp())

  tcp:connect(host, port)

--some code here

  tcp:send(value)
  tcp:close()


this is SSL unsecured, when I want to send value to server, 

and when I receive data I create socket and send feedback data via

socket:send(value);   


Is there some simple way to secure this communication with SSL in LogicMachine's Lua script? 

Thank you!

Marek H.
Reply
#2
Have a look here for HTTPS requests:
http://openrb.com/docs/lua.htm#ssl.https.request

If you need SSL for raw sockets, I can provide an example later.
Reply
#3
(03.02.2016, 16:12)admin Wrote: Have a look here for HTTPS requests:
http://openrb.com/docs/lua.htm#ssl.https.request

If you need SSL for raw sockets, I can provide an example later.

Thank you!

And I need also SSL for raw socket and copas. 

Thanks alot Smile
Reply
#4
For now we only have support for SSL/TLS in client mode, here's a short example. If handshake fails, try setting proto to tlsv1.

Code:
require('socket')
require('ssl')

host = '127.0.0.1'
port = '443'
proto = 'tlsv12' -- can also be 'tlsv1' or 'tlsv11'

sock = socket.tcp()
res, err = sock:connect(host, port)
if res then
  sock = ssl.wrap(sock, proto)
  res, err = sock:dohandshake()

  if res then
    ...
  else
    log('Handshake failed', err)
  end
else
  log('Connect failed', err)
end

sock:close()
Reply
#5
(04.02.2016, 09:42)admin Wrote: For now we only have support for SSL/TLS in client mode, here's a short example. If handshake fails, try setting proto to tlsv1.

Code:
require('socket')
require('ssl')

host = '127.0.0.1'
port = '443'
proto = 'tlsv12' -- can also be 'tlsv1' or 'tlsv11'

sock = socket.tcp()
res, err = sock:connect(host, port)
if res then
 sock = ssl.wrap(sock, proto)
 res, err = sock:dohandshake()

 if res then
   ...
 else
   log('Handshake failed', err)
 end
else
 log('Connect failed', err)
end

sock:close()

Thank you, 

Is it possible to make it also for server mode (copas)? 

Marek H.
Reply
#6
Give us some time to finish the next FW release, then we'll update the SSL library with server part Smile
Reply


Forum Jump: