storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/docs/zh_CN/tls/README.md (about) 1 # 使用TLS安全的访问Minio服务[](https://slack.min.io) 2 3 本文,我们讲介绍如何在Linux和Windows上配置Minio服务使用TLS。 4 5 ## 1. 前提条件 6 7 * 下载Minio server [这里](https://docs.min.io/docs/minio-quickstart-guide) 8 9 ## 2. 配置已存在的证书 10 11 如果你已经有私钥和公钥证书,你需要将它们拷贝到Minio的config/`certs`文件夹,分别取名为`private.key` 和 `public.crt`。 12 13 如果这个证书是被证书机构签发的,`public.crt`应该是服务器的证书,任何中间体的证书以及CA的根证书的级联。 14 15 ## 3. 生成证书 16 17 ### Linux 18 19 Minio在Linux只支持使用PEM格式的key/certificate。 20 21 #### 使用 Let's Encrypt 22 23 更多信息,请访问 [这里](https://docs.min.io/cn/generate-let-s-encypt-certificate-using-concert-for-minio) 24 25 #### 使用 generate_cert.go (self-signed certificate) 26 27 你需要下载 [generate_cert.go](https://golang.org/src/crypto/tls/generate_cert.go?m=text),它是一个简单的go工具,可以生成自签名的证书,不过大多数情况下用着都是木有问题的。 28 29 `generate_cert.go` 已经提供了带有DNS和IP条目的SAN证书: 30 31 ```sh 32 go run generate_cert.go -ca --host "10.10.0.3" 33 ``` 34 35 #### 使用 OpenSSL: 36 37 生成私钥: 38 39 ```sh 40 openssl genrsa -out private.key 2048 41 ``` 42 43 生成自签名证书: 44 45 ```sh 46 openssl req -new -x509 -days 3650 -key private.key -out public.crt -subj "/C=US/ST=state/L=location/O=organization/CN=domain" 47 ``` 48 49 ### Windows 50 51 Minio在Windows上只支持PEM格式的key/certificate,目前不支持PFX证书。 52 53 #### 安装 GnuTLS 54 55 下载并解压[GnuTLS](http://www.gnutls.org/download.html) 56 57 确保将解压后的binary路径加入到系统路径中。 58 59 ``` 60 setx path "%path%;C:\Users\MyUser\Downloads\gnutls-3.4.9-w64\bin" 61 ``` 62 63 你可能需要重启powershell控制台来使其生效。 64 65 #### 生成private.key 66 67 运行下面的命令来生成 `private.key` 68 69 ``` 70 certtool.exe --generate-privkey --outfile private.key 71 ``` 72 73 #### 生成public.crt 74 75 创建文件`cert.cnf`,填写必要信息来生成证书。 76 77 ``` 78 # X.509 Certificate options 79 # 80 # DN options 81 82 # The organization of the subject. 83 organization = "Example Inc." 84 85 # The organizational unit of the subject. 86 #unit = "sleeping dept." 87 88 # The state of the certificate owner. 89 state = "Example" 90 91 # The country of the subject. Two letter code. 92 country = "EX" 93 94 # The common name of the certificate owner. 95 cn = "Sally Certowner" 96 97 # In how many days, counting from today, this certificate will expire. 98 expiration_days = 365 99 100 # X.509 v3 extensions 101 102 # DNS name(s) of the server 103 dns_name = "localhost" 104 105 # (Optional) Server IP address 106 ip_address = "127.0.0.1" 107 108 # Whether this certificate will be used for a TLS server 109 tls_www_server 110 111 # Whether this certificate will be used to encrypt data (needed 112 # in TLS RSA ciphersuites). Note that it is preferred to use different 113 # keys for encryption and signing. 114 encryption_key 115 ``` 116 117 生成公钥证书 118 119 ``` 120 certtool.exe --generate-self-signed --load-privkey private.key --template cert.cnf --outfile public.crt 121 ``` 122 123 ## 4. 安装第三方CAs 124 125 Minio可以配置成连接其它服务,不管是Minio节点还是像NATs、Redis这些。如果这些服务用的不是在已知证书机构注册的证书,你可以让Minio服务信任这些CA,怎么做呢,将这些证书放到Minio配置路径下 126 * **Linux:** `~/.minio/certs/CAs/` 127 * **Windows**: `C:\Users\<Username>\.minio\certs\CAs` 128 129 # 了解更多 130 * [Minio快速入门](https://docs.min.io/cn/minio-quickstart-guide) 131 * [Minio客户端权威指南](https://docs.min.io/cn/minio-client-complete-guide)