monkeyDluffy6017 commented on code in PR #10773:
URL: https://github.com/apache/apisix/pull/10773#discussion_r1444146439
##########
docs/en/latest/mtls.md:
##########
@@ -170,41 +187,15 @@ When configuring `upstreams`, we could use parameter
`tls.client_cert` and `tls.
This feature requires APISIX to run on
[APISIX-Runtime](./FAQ.md#how-do-i-build-the-apisix-runtime-environment).
-Here is a similar Python script to patch a existed upstream with mTLS (changes
admin API url if needed):
-
-```python title="patch_upstream_mtls.py"
-#!/usr/bin/env python
-# coding: utf-8
-import sys
-# sudo pip install requests
-import requests
-
-if len(sys.argv) < 4:
- print("bad argument")
- sys.exit(1)
-with open(sys.argv[2]) as f:
- cert = f.read()
-with open(sys.argv[3]) as f:
- key = f.read()
-id = sys.argv[1]
-api_key = "edd1c9f034335f136f87ad84b625c8f1" # Change it
-
-reqParam = {
- "tls": {
- "client_cert": cert,
- "client_key": key,
- },
-}
-
-resp = requests.patch("http://127.0.0.1:9180/apisix/admin/upstreams/"+id,
json=reqParam, headers={
- "X-API-KEY": api_key,
-})
-print(resp.status_code)
-print(resp.text)
-```
-
-Patch existed upstream with id `testmtls`:
+Here is a similar shell script to patch a existed upstream with mTLS (changes
admin API url if needed):
-```bash
-./patch_upstream_mtls.py testmtls ./client.pem ./client.key
+```shell
+curl http://127.0.0.1:9180/apisix/admin/upstreams/1 \
+-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PATCH -d '
+{
+ "tls": {
+ "client_cert": "'"$(cat t/certs/mtls_client.crt)"'",
+ "client_key": "'"$(cat t/certs/mtls_client.key)"'"
+ }
+}'
Review Comment:
This command will produce the following error:
```
curl http://127.0.0.1:9180/apisix/admin/upstreams/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PATCH -d '
{
"tls": {
"client_cert": "'"$(cat t/certs/mtls_client.crt)"'",
"client_key": "'"$(cat t/certs/mtls_client.key)"'"
}
}'
{"message":"Key not found"}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]