最近装了太阳能板,想用 lambda + grafana + prometheus 爬一下逆变器的各种数据做个简单的 dashboard.
然后发现华为光伏的 API 文档写的实在有点粗糙..
还有一些不能理解的地方:
- https 证书居然还是 self signed,居然连个证书都不舍得?
- 登录居然要把用户名和密码在 URL 里面传...
- 登录失败不返回 401,返回 200...
curl -vkX POST \ 'https://au1.fusionsolar.huawei.com:27200/openApi/login?userName=FOO&password=BAR' * Trying 54.153.220.93... * TCP_NODELAY set * Connected to au1.fusionsolar.huawei.com (54.153.220.93) port 27200 (#0) * ALPN, offering h2 * ALPN, offering http/1.1 * Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH * successfully set certificate verify locations: * CAfile: /etc/ssl/cert.pem CApath: none * TLSv1.2 (OUT), TLS handshake, Client hello (1): * TLSv1.2 (IN), TLS handshake, Server hello (2): * TLSv1.2 (IN), TLS handshake, Certificate (11): * TLSv1.2 (IN), TLS handshake, Request CERT (13): * TLSv1.2 (IN), TLS handshake, Server finished (14): * TLSv1.2 (OUT), TLS handshake, Certificate (11): * TLSv1.2 (OUT), TLS handshake, Client key exchange (16): * TLSv1.2 (OUT), TLS change cipher, Client hello (1): * TLSv1.2 (OUT), TLS handshake, Finished (20): * TLSv1.2 (IN), TLS change cipher, Client hello (1): * TLSv1.2 (IN), TLS handshake, Finished (20): * SSL connection using TLSv1.2 / AES128-SHA * ALPN, server did not agree to a protocol * Server certificate: * subject: C=CN; ST=Guangdong; L=Shenzhen; O=Huawei; OU=Network Energy; CN=NetEcoServer * start date: Mar 18 01:23:06 2015 GMT * expire date: Mar 13 01:23:06 2035 GMT * issuer: C=CN; O=huawei; OU=Network Energy; CN=NEPL PKI * SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway. > POST /openApi/login?userName=FOO&password=BAR HTTP/1.1 > Host: au1.fusionsolar.huawei.com:27200 > User-Agent: curl/7.54.0 > Accept: */* > < HTTP/1.1 200 OK < Date: Tue, 08 Oct 2019 13:02:55 GMT < Set-Cookie: JSESSIONID=1jsi0rnxij5mzokex34wnr7ig;Path=/;Secure;HttpOnly < Expires: Thu, 01 Jan 1970 00:00:00 GMT < Cache-Control: no-cache < X-Frame-Options: SAMEORIGIN < X-Download-Options: noopen < X-XSS-Protection: 1;mode=block < Strict-Transport-Security: max-age=31536000;includeSubdomains < X-Content-Type-Options: nosniff < Vary: Accept-Encoding, User-Agent < Transfer-Encoding: chunked < {"errorMsg":309} * Connection #0 to host au1.fusionsolar.huawei.com left intact
文档参考: