Skip to content

Commit

Permalink
fix client cert file loading problem
Browse files Browse the repository at this point in the history
  • Loading branch information
p4gefau1t committed Mar 23, 2020
1 parent 89530d1 commit 037b698
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ It's fully compatible with the Trojan protocol and configuration file, so that y

### Easy to use

Trojan-go's configuration file format is compatible with Trojan's, while it's being simplyfied. Unspecified fields will be filled in with a default value. You can launch your server and client much more easily. Here's an example:
Trojan-go's configuration file format is compatible with Trojan's, while it's being simplyfied. Unspecified fields will be filled in with a default value. You can launch your server and client much easier. Here's an example:

server.json
```
Expand Down Expand Up @@ -76,7 +76,6 @@ client.json
"your_awesome_password"
],
"ssl": {
"cert": "your_cert.crt",
"sni": "your_awesome_domain_name"
}
}
Expand Down Expand Up @@ -150,11 +149,11 @@ go build

You can cross-compile it by setting up the environment vars, for example
```
GOOS=windows GOARCH=amd64 go build -o trojan-go.exe
CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o trojan-go.exe
```

or

```
GOOS=linux GOARCH=arm go build -o trojan-go
CGO_ENABLE=0 GOOS=linux GOARCH=arm go build -o trojan-go
```
8 changes: 3 additions & 5 deletions README_zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ client.json
"your_awesome_password"
],
"ssl": {
"cert": "your_cert.crt",
"sni": "your_awesome_domain_name"
}
}
Expand All @@ -90,7 +89,7 @@ Trojan-Go支持的runtype包括(其实和原版是一样的)

- Server

- NAT (透明代理,[参见这里](https://github.com/shadowsocks/shadowsocks-libev/tree/v3.3.1#transparent-proxy))
- NAT (透明代理,参见[这里](https://github.com/shadowsocks/shadowsocks-libev/tree/v3.3.1#transparent-proxy))

- Forward

Expand Down Expand Up @@ -144,7 +143,6 @@ client-mux.json

确保你的Golang版本 >= 1.11


```
git clone https://github.com/p4gefau1t/trojan-go.git
cd trojan-go
Expand All @@ -154,10 +152,10 @@ go build
Golang支持通过设置环境变量进行交叉编译,例如

```
GOOS=windows GOARCH=amd64 go build -o trojan-go.exe
CGO_ENABLE=0 GOOS=windows GOARCH=amd64 go build -o trojan-go.exe
```
以及

```
GOOS=linux GOARCH=arm go build -o trojan-go
CGO_ENABLE=0 GOOS=linux GOARCH=arm go build -o trojan-go
```
6 changes: 5 additions & 1 deletion conf/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ func ParseJSON(data []byte) (*GlobalConfig, error) {
if len(config.Passwords) == 0 {
return nil, common.NewError("no password found")
}
if config.TLS.CertPath == "" {
logger.Warn("cert of the remote server is not specified. using default CA list.")
break
}
serverCertBytes, err := ioutil.ReadFile(config.TLS.CertPath)
if err != nil {
return nil, err
return nil, common.NewError("failed to load cert file").Base(err)
}
pool := x509.NewCertPool()
pool.AppendCertsFromPEM(serverCertBytes)
Expand Down

0 comments on commit 037b698

Please sign in to comment.