연결을 끊고 명령을 실행하는 SSL 서버 설정 읽었지만이를 구현하는 가장 좋은 방법에 대한

포트에서 수신 대기하는 간단한 SSL 서버를 설정하는 방법과 장치가 연결될 때 장치에 연결을 끊고 명령을 실행하는 방법에 대한 제안을 찾고 있습니다.

컨텍스트 : 장치는 Amazon 대시이며 연결할 때 메시지가 암호화되지만 메시지는 신경 쓰지 않습니다.

openwrt 라우터에서 이것을 실행할 것입니다

netcat 및 openssl s_server 사용에 대해 읽었지만이를 구현하는 가장 좋은 방법에 대한 피드백과 제안을 원합니다.

다음은 netcat을 사용하는 현재 솔루션입니다.

while true; do
    netcat -vv -l -p 443 -c < /www/default.html
    curl -X POST http://maker.ifttt.com/trigger/button_pressed/with/key/<MY KEY>
    sleep 5

끝난

이 솔루션에 대한 의견이 있으십니까?



답변

대시 버튼을 속이도록 SSL 서버를 설정하는 데 필요한 지침을 찾았습니다.

https://mpetroff.net/2015/05/amazon-dash-button-teardown/

(2015 년 8 월 9 일 오후 5시 39 분에 게시 된 Mark의 의견 아래 참조)

그는 https://gist.github.com/jonathantneal/774e4b0b3d4d739cbc53 의 웹 서버를 사용했습니다.

위의 정보를 사용하여 자체 SSL 서버를 작성할 수있었습니다.

import BaseHTTPServer, SimpleHTTPServer, ssl

class MyHTTPHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(s):
        print 'GET', s.path

    def do_POST(s):
        print 'POST', s.path

if __name__ == "__main__":
    # Create the server, binding to localhost on port 443
    httpd = BaseHTTPServer.HTTPServer(('', 443), MyHTTPHandler)
    httpd.socket = ssl.wrap_socket (httpd.socket, certfile='cert.pem', server_side=True)
    httpd.serve_forever()

그리고 다음과 같은 출력을 얻습니다.

POST /2/b
POST /2/d
POST /2/d
POST /2/d

위의 내용은 모두 한 번의 프레스입니다. 그러나 들어오는 연결 만 처리하는 일반 TCP 서버보다 유용하지 않습니다. 한 번 누르기, 두 번 누르기 및 길게 누르기 간에는 차이가 없습니다.

(자체 서명 인증서를 신뢰하려면 대시 버튼을 속일 필요가 있습니다. 이것이 내가 한 일입니다)

$ openssl req -x509 -newkey rsa:2048 -out cert.pem -nodes -keyout cert.pem
Generating a 2048 bit RSA private key
.................................................+++
..................................................................................................................+++
writing new private key to 'cert.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:Washington
Locality Name (eg, city) []:Seattle
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:Amazon.com, Inc.
Common Name (e.g. server FQDN or YOUR name) []:parker-gateway-na.amazon.com
Email Address []:


답변