简体   繁体   English

在 curl PUT 语句中使用 OUuth2.der 令牌作为授权 header

[英]Use OUuth2 .der token as Authorization header in curl PUT statement

I think I need to decode my .der file to use as a public key, but I can't find a cli command to do this.我想我需要解码我的.der文件以用作公钥,但我找不到执行此操作的cli命令。

I'm getting the error <h1>Bad Message 400</h1><pre>reason: Illegal character CNTL=0x2</pre>0我收到错误<h1>Bad Message 400</h1><pre>reason: Illegal character CNTL=0x2</pre>0

CLUSTER=standalone
TENANT=sandbox
NAMESPACE=integration_test
AUTHORIZATION=$(cat /tmp/event-platform/oauth2_public.der)

# Create tenant
curl -L -X PUT "http://localhost:$HOST_PULSAR_PORT/admin/v2/tenants/$TENANT" \
    --header "Authorization: Bearer $AUTHORIZATION" \
    --header 'Content-Type: application/json' \
    --data-raw "{\"allowedClusters\": [\"$CLUSTER\"]}"

echo $?

Well a DER file contains binary characters so you should encode it before sending: DER 文件包含二进制字符,因此您应该在发送之前对其进行编码:

AUTHORIZATION=$(cat /tmp/event-platform/oauth2_public.der | base64)

A certificate file is not a bearer token though.但是,证书文件不是不记名令牌。 If it is a client certificate credential, then maybe consider this type of syntax for sending it:如果它是客户端证书凭证,那么可以考虑使用这种类型的语法来发送它:

curl -s -X POST someUrl \
--cert ./certs/example.client.pem \
--key ./certs/example.client.key \
--cacert ./certs/root.pem

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM