我试图按照链接中定义的步骤" https://didproject.azurewebsites.net/docs/registration.html",就像没有任何更改以创建示例一样完整的注册以了解该过程。
我下载了样本并生成了必要的公共/私钥,并完成了使用成功的命令节点makejws生成有效载荷的步骤。
之后,当我尝试使用curl命令" curl"之后,通过替换整个文本之后 - 与命令节点Makejws有效载荷响应的数据。我收到错误的要求,不确定命令中有什么问题
我使用的curl命令如下
curl -v -h" content -type:application/json" - data" {'header':{'alg':'es256k','kid':'#key -1','operation','operation':'创建','' a.ion.microsoft.com/api/1.0/register
以下响应
除外"HTTP/1.1 200 OK
Content-Length: 395
Content-Type: application/json"
但是接收
HTTP/1.1 400 Bad Request
request-id: "test"
content-type: text/plain; charset=
您使用的curl命令不是发送JSON。JSON需要围绕密钥和值的"双引号"。
更改您的所有",然后将其包裹在'中:
--data '{"header":{"alg":"ES256K",...}' -X POST https://beta.ion.microsoft.com/api/1.0/register
当我这样做时,我收到了HTTP/1.1 200 OK
(另外,-X POST
也不需要-POST
已由curl
命令的其他部分暗示。(
更新1 根据您的6/30评论,我以我的意思是我的意思的毫无用处的形式更新了此答案,卷曲输出显示其有效:
完整的curl命令
curl -v -H "Content-Type: application/json" --data '{"header":{"alg":"ES256K","kid":"#key-1","operation":"create","proofOfWork":"{}"},"payload":"eyJAY29udGV4dCI6Imh0dHBzOi8vdzNpZC5vcmcvZGlkL3YxIiwicHVibGljS2V5IjpbeyJpZCI6IiNrZXktMSIsInR5cGUiOiJTZWNwMjU2azFWZXJpZmljYXRpb25LZXkyMDE4IiwicHVibGljS2V5SndrIjp7Imt0eSI6IkVDIiwia2lkIjoiI2tleS0xIiwiY3J2IjoiUC0yNTZLIiwieCI6IjVvTEg2ZUVfdWZjZ2VlZ1U2NFo1ZFlEdUxjWWJSV3hsYk1xdFVnbmVRRWMiLCJ5IjoieXZEcXhwaXlCYlZsUlF1cXhHUm54U3hNbDJwSFFTem5Ub0U1dTZKMzBkSSIsInVzZSI6InZlcmlmeSIsImRlZmF1bHRFbmNyeXB0aW9uQWxnb3JpdGhtIjoibm9uZSIsImRlZmF1bHRTaWduQWxnb3JpdGhtIjoiRVMyNTZLIn19XSwic2VydmljZSI6W3siaWQiOiJJZGVudGl0eUh1YiIsInR5cGUiOiJJZGVudGl0eUh1YiIsInNlcnZpY2VFbmRwb2ludCI6eyJAY29udGV4dCI6InNjaGVtYS5pZGVudGl0eS5mb3VuZGF0aW9uL2h1YiIsIkB0eXBlIjoiVXNlclNlcnZpY2VFbmRwb2ludCIsImluc3RhbmNlIjpbImRpZDp0ZXN0Omh1Yi5pZCJdfX1dfQ","signature":"MEYCIQCb7qxCFyIcYumN-HbYqleTc5YldwRnNrhDzlB1DEubQQIhAMkAdsa-BxwV5EghhLljbr84MjkmUYI5narCTnapBcxs"}' -X POST https://beta.ion.microsoft.com/api/1.0/register
卷曲传输
Note: Unnecessary use of -X or --request, POST is already inferred.
* Trying 52.183.24.15...
* TCP_NODELAY set
* Connected to beta.ion.microsoft.com (52.183.24.15) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/ssl/cert.pem
CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=beta.ion.microsoft.com
* start date: Apr 25 21:41:42 2019 GMT
* expire date: Apr 25 21:41:42 2020 GMT
* subjectAltName: host "beta.ion.microsoft.com" matched cert's "beta.ion.microsoft.com"
* issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT TLS CA 2
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f9e0e00c600)
> POST /api/1.0/register HTTP/2
> Host: beta.ion.microsoft.com
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 908
>
卷曲响应
* We are completely uploaded and fine
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 200
< request-id: 3545fb10-998e-4871-a28c-bc92e7d82648
< vary: Origin, Accept-Encoding
< x-dns-prefetch-control: off
< x-frame-options: SAMEORIGIN
< strict-transport-security: max-age=31536000; includeSubDomains
< x-download-options: noopen
< x-content-type-options: nosniff
< x-xss-protection: 1; mode=block
< content-type: application/json; charset=utf-8
< content-length: 828
< server-timing: total;dur=171.0000
< date: Mon, 01 Jul 2019 03:56:45 GMT
< x-envoy-upstream-service-time: 173
< server: envoy
<
{
"@context": "https://w3id.org/did/v1",
"publicKey": [
{
"id": "#key-1",
"type": "Secp256k1VerificationKey2018",
"publicKeyJwk": {
"kty": "EC",
"kid": "#key-1",
"crv": "P-256K",
"x": "5oLH6eE_ufcgeegU64Z5dYDuLcYbRWxlbMqtUgneQEc",
"y": "yvDqxpiyBbVlRQuqxGRnxSxMl2pHQSznToE5u6J30dI",
"use": "verify",
"defaultEncryptionAlgorithm": "none",
"defaultSignAlgorithm": "ES256K"
}
}
],
"service": [
{
"id": "IdentityHub",
"type": "IdentityHub",
"serviceEndpoint": {
"@context": "schema.identity.foundation/hub",
"@type": "UserServiceEndpoint",
"instance": [
"did:test:hub.id"
]
}
}
],
"id": "did:ion:test:EiBXX4kWVIMsvP-evbWvr37Vy2UY32ALpNu9nssBhj_Pdg"
* Connection #0 to host beta.ion.microsoft.com left intact