2013-08-27 39 views
3

我很努力地用nginx代理上游的SSL。我意識到,代理到HTTPS是浪費,但這是我的設置,有時API可以直接訪問,有時我使用nginx來服務JS應用程序,這也是API的客戶端,CORS和瀏覽器安全要求JS應用程序與應用程序服務於同一個域進行通信:nginx代理傳遞給sslv3上游

+--------------------+      +---------------------+ 
|     |+-------------------->|      | 
| Pure HTTP API Host |      | CLI Tool API Client | 
|     |<--------------------+|      | 
+--------------------+      +---------------------+ 
     |^(:3152) 
     | | 
     | |    |    +---------------------+ 
     | +--------------------------------|      | 
     |     |    | Javascript App  | 
     +---------------------------------->|      | 
          |    +---------------------+ 
          | 

         nginx proxy for CORS 

因爲這樣,這裏是堆棧。該API主機寫入GoLang,服務利用startssl如果一個簽名的證書:該輸出

$ openssl s_client -ssl3 -connect local.api.theproject.io:3251 
Secure Renegotiation IS NOT supported 
Compression: NONE 
Expansion: NONE 
SSL-Session: 
    Protocol : SSLv3 
    Cipher : AES256-SHA 
    Session-ID: 
    Session-ID-ctx: 
    Master-Key: E021B27717F5A4 
    Key-Arg : None 
    Start Time: 1377589306 
    Timeout : 7200 (sec) 
    Verify return code: 21 (unable to verify the first certificate) 

我已經被截斷,但足以說,圍棋的ListenAndServeTLS只出現與SSLv3的工作,如下面的失敗:

$ openssl s_client -connect local.api.theproject.io:3251 
CONNECTED(00000003) 
35899:error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version:/SourceCache/OpenSSL098/OpenSSL098-47.1/src/ssl/s23_clnt.c:602: 

這樣出來的nginx的問題是明確的:

2013/08/27 09:30:21 [error] 35674#0: *3 kevent() reported that connect() failed (61: 
Connection refused) while connecting to upstream, client: 127.0.0.1, server: 
local.www.theproject.io, request: "GET/HTTP/1.1", upstream: "https://[::1]:3251//", 
host: "local.www.theproject.io:4443" 
2013/08/27 09:30:21 [error] 35674#0: *3 SSL_do_handshake() failed (SSL: error:1407742 
E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version) while SSL handshaking 
to upstream, client: 127.0.0.1, server: local.www.theproject.io, request: "GET/
HTTP/1.1", upstream: "https://127.0.0.1:3251//", host: "local.www.theproject.io:4443" 

注:我USI

proxy_set_header Host $http_host; 
    proxy_set_header X-Real-IP $remote_addr; 
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
    proxy_set_header X-Forwarded-Proto https; 
    proxy_pass https://local.api.theproject.io:3251/; 

爲了得到這個代理正確使用SSLv3的內部:NG [::1]這裏,但是這並不顯著,它也失敗課程127.0.0.1

因此,目前的問題是,什麼是從失蹤?

回答

1

您是否嘗試過「ssl_ciphers ALL」?

儘管不推薦這樣做(因爲這樣可以減弱密碼),但這會縮小問題的範圍。如果這不起作用,最可能的原因是你使用的openssl沒有合適的密碼來完成你的Go服務器的SSL握手。

請注意,Go的tls軟件包僅「部分」實施,並且supported ciphers非常有限。

解決辦法有兩個:

  1. 你必須升級支持什麼Go的TLS包已經實現了你的OpenSSL版本。然後,當然,重新編譯你的nginx。
  2. 你必須修補TLS包加入適當suite ids在TLS/cipher_suites.go密碼套件支持不論您目前openssl ciphers提供(我認爲)