Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client certificate #10

Merged
merged 5 commits into from
Nov 22, 2022
Merged

Client certificate #10

merged 5 commits into from
Nov 22, 2022

Conversation

Yamaguchi
Copy link
Contributor

Sample code to use client certificates.

@Yamaguchi Yamaguchi force-pushed the feature/client_certificate branch from c588268 to c71f496 Compare July 26, 2022 07:01
@Yamaguchi Yamaguchi force-pushed the feature/client_certificate branch from c71f496 to 73516d7 Compare July 26, 2022 09:15
Copy link
Contributor

@rantan rantan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GettingStarted-ja.md も更新が必要です。

@rantan
Copy link
Contributor

rantan commented Oct 12, 2022

@Yamaguchi 認証を試みたときに、以下のエラーで失敗します。なにか心当たりありますか?

$ node index.js 
Example app listening at http://localhost:3000
node:internal/tls/secure-context:277
      context.loadPKCS12(toBuf(pfx), toBuf(passphrase));
              ^

Error: unsupported
    at configSecureContext (node:internal/tls/secure-context:277:15)
    at Object.createSecureContext (node:_tls_common:117:3)
    at Object.connect (node:_tls_wrap:1629:48)
    at Agent.createConnection (node:https:150:22)
    at Agent.createSocket (node:_http_agent:350:26)
    at Agent.addRequest (node:_http_agent:297:10)
    at new ClientRequest (node:_http_client:335:16)
    at Object.request (node:https:360:10)
    at internals.Client._request (/home/rantan/repos/chaintope/tapyrus-api-client-examples/javascript/example-app/node_modules/@hapi/wreck/lib/index.js:181:28)
    at internals.Client.request (/home/rantan/repos/chaintope/tapyrus-api-client-examples/javascript/example-app/node_modules/@hapi/wreck/lib/index.js:75:26)

Node.js v18.10.0

@rantan
Copy link
Contributor

rantan commented Oct 12, 2022

現在クライアント証明書で使用しているアルゴリズムが古く OpenSSL 3 では無効になっているようです。node 17 からは openssl 3 へ移行しており、その影響でこのエラーが出ているようです。

$ openssl pkcs12 -info -in user.p12 -noout
Enter Import Password:
MAC: sha1, Iteration 1
MAC length: 20, salt length: 8
PKCS7 Encrypted data: pbeWithSHA1And40BitRC2-CBC, Iteration 2048
Certificate bag
PKCS7 Data
Shrouded Keybag: pbeWithSHA1And3-KeyTripleDES-CBC, Iteration 2048

参考: nodejs/node#40672 (comment)

@rantan
Copy link
Contributor

rantan commented Oct 12, 2022

以下のように起動することで、エラーを回避し、認証に成功しました。

$ node --openssl-legacy-provider index.js 

ただし、クライアント証明書に利用しているアルゴリズムの見直しは必要ですね。

@rantan
Copy link
Contributor

rantan commented Oct 12, 2022

アルゴリズムの見直しについては Issue にしました。
https://github.com/chaintope/tapyrus-api-ca/issues/10

@Yamaguchi
Copy link
Contributor Author

GettingStarted-ja.md も更新が必要です。

6b1c1b8912202e4d57c7f4c3edba1539dd040e76で変更しました。

@Yamaguchi Yamaguchi requested a review from rantan October 24, 2022 17:56
@Yamaguchi Yamaguchi requested a review from rantan November 10, 2022 17:35
Copy link
Contributor

@rantan rantan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

「このドキュメントのゴール」にある以下の2項目は消した方が良いと思います。1つ目は今は不要な操作ですし、2つ目は、Tapyrus API Mainnet ではエクスプローラー環境を用意していないので達成できませんし。

  • Tapyrus API ユーザーのウォレットに TPC を供給して、トランザクションを発行する API の準備の方法を理解する。
  • Tapyrus API で行った操作によって作られたトランザクションをエクスプローラーで確認する方法を理解する。

「対象とするブロックチェーン」の部分は、利用する Tapyrus API endpoint に依存するため、このドキュメントからは除外してよいと思います。

ちょっと PR の趣旨からずれてきますが、TPC の送金 API は今は使えないので、この Example の構成も token の発行・送金をする形にするなど変更が必要ですね。。


## 6. TPC を入手する

今回はテストネットを例に使っていますので、テストネットのfaucetからコインを手に入れます。 テストネット以外のネットワークを利用する場合は、その Tapyrus チェーンを運営しているフェデレーションの案内を確認してください。
今回はテストネットを例に使っていますので、テストネットのfaucetからコインを入手します。 テストネット以外のネットワークを利用する場合は、その Tapyrus チェーンを運営しているフェデレーションの案内を確認してください。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

見逃していましたが、Tapyrus API を使うにあたって faucet からの TPC の入手は不要ですね。

@Yamaguchi Yamaguchi force-pushed the feature/client_certificate branch from d281667 to b426274 Compare November 14, 2022 13:54
@rantan rantan merged commit 219251a into main Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants