dingmaotu / mql-zmq

ZMQ binding for the MQL language (both 32bit MT4 and 64bit MT5)
Apache License 2.0
553 stars 301 forks source link

Authentication #38

Closed Deeptradingfx closed 5 years ago

Deeptradingfx commented 5 years ago

There is a way add authentication from pubsup some sort of custom token or key should i change the numbers for my code ?

define ZMQ_PLAIN_USERNAME 45

-- 83 | #define ZMQ_PLAIN_PASSWORD 46 84 | #define ZMQ_CURVE_SERVER 47 85 | #define ZMQ_CURVE_PUBLICKEY 48

Deeptradingfx commented 5 years ago

ANY ONE COULD HELP ME HOW TO KEEP THE COMMUNICATION SAFETY TO PERMIT ONLY AUTHORIZED SUBSCRIBERS

dingmaotu commented 5 years ago

You should check ZEROMQ official documentation, which may have authentication related topic.

Deeptradingfx commented 5 years ago

You should check ZEROMQ official documentation, which may have authentication related topic.

Yes i did it from python but i couldnt find it on your library can you give a exemplo on the library where to set a new public key please im working on it for about 120 days and i dont know mql very well

Deeptradingfx commented 5 years ago

Please Mr Ding post a example using curve pupsub

Deeptradingfx commented 5 years ago

I would like to share how I did the authentication with curve I do not know if this is correct! but did work.

` Print(">>> Generator for keys Public and secret");

string genpub,gensec; Z85::generateKeyPair(genpub,gensec); Print("1) Generated public key: ",genpub); Print("1) Generated private key: ",gensec); `

Server part ` Context context("helloworld");

Socket socket(context,ZMQ_REP); socket.setCurvePublicKey("server publickey "); socket.setCurveSecretKey("server secretkey"); socket.setCurveServer(true); \ needs to come b4 bind or connect socket.bind("tcp://*:5561");`

now the client must have diferente public key and secretkey

`// Prepare our context and socket Context context("helloworld");

Socket socket(context,ZMQ_REQ); socket.setCurvePublicKey("client publickey"); \ new public key
socket.setCurveSecretKey("client secretkey"); \ new secret key socket.setCurveServerKey("Server public key "); \ same server public key socket.connect("tcp://localhost:5561");`

one more thing the client publickey and secrect key could be random but server has to be static

the client could be like that

` string genpub,gensec; Z85::generateKeyPair(genpub,gensec);

// Prepare our context and socket

Context context("helloworld"); Socket socket(context,ZMQ_REQ); socket.setCurvePublicKey(gensec); socket.setCurveSecretKey(genpub);

socket.setCurveServerKey("Server static publickey"); socket.connect("tcp://localhost:5561");`