hyperledger-cacti / cacti

Hyperledger Cacti is a new approach to the blockchain interoperability problem
https://wiki.hyperledger.org/display/cactus
Apache License 2.0
344 stars 286 forks source link

fix(cmd-api-server): plugin import - asn1 illegal padding #647

Open petermetz opened 3 years ago

petermetz commented 3 years ago

Describe the bug

A quite strange flake. 3 out of the 4 CI runs succeeded for my PR but this one failed with the error mentioned in the subject while executing the test at ./packages/cactus-cmd-api-server/src/test/typescript/integration/runtime-plugin-imports.test.ts

To Reproduce

Not sure, could be some race condition internal to NodeJS itself. I doubt we'll be able to reproduce it to be honest.

Expected behavior

Test does not fail.

Logs/Stack traces

https://github.com/petermetz/cactus/runs/2071676202?check_suite_focus=true#step:10:179


ok 4 - packages/cactus-cmd-api-server/src/test/typescript/integration/remote-plugin-imports.test.ts # time=27952.046ms

# Subtest: packages/cactus-cmd-api-server/src/test/typescript/integration/runtime-plugin-imports.test.ts
    # can import plugins at runtime (CLI)
    Warning: configuration param 'type' not declared in the schema
    [2021-03-10T02:03:56.784Z] INFO (config-service): Configuration validation OK.
    not ok 1 Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
      ---
        operator: error
        at: bound (/home/runner/work/cactus/cactus/node_modules/onetime/index.js:30:12)
        stack: |-
          Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
              at Object.createSecureContext (_tls_common.js:129:17)
              at Server.setSecureContext (_tls_wrap.js:1323:27)
              at Server (_tls_wrap.js:1181:8)
              at new Server (https.js:66:14)
              at Object.createServer (https.js:91:10)
              at new ApiServer (/home/runner/work/cactus/cactus/packages/cactus-cmd-api-server/src/main/typescript/api-server.ts:1:25253)
              at /home/runner/work/cactus/cactus/packages/cactus-cmd-api-server/src/test/typescript/integration/runtime-plugin-imports.test.ts:34:21
              at Test.<anonymous> (/home/runner/work/cactus/cactus/node_modules/tape-promise/index.compiled.js:86:19)
              at Test.bound [as _cb] (/home/runner/work/cactus/cactus/node_modules/tape/lib/test.js:84:32)
              at Test.run (/home/runner/work/cactus/cactus/node_modules/tape/lib/test.js:101:31)
      ...

    Bail out! Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
Bail out! Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
----------------------------------------------------------------------------------------|----------|----------|----------|----------|-------------------|
File                                                                                    |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------------------------------------------------------------------------------------|----------|----------|----------|----------|-------------------|
All files                                                                               |    38.28 |    21.51 |    25.44 |    37.96 |                   |
 cactus-api-client/src/main/typescript                                                  |    44.26 |    33.33 |    45.45 |    42.37 |                   |
  api-client.ts                                                                         |       20 |        0 |        0 |       20 |... 29,131,133,137 |
  default-consortium-provider.ts                                                        |    61.54 |       60 |       75 |    61.54 |... 47,50,52,59,65 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  public-api.ts                                                                         |      100 |      100 |      100 |      100 |                   |
 cactus-cmd-api-server/src/main/typescript                                              |    81.22 |    46.15 |    65.52 |    81.77 |                   |
  api-server.ts                                                                         |    80.32 |    46.15 |       68 |    81.08 |... 72,373,375,377 |
  public-api.ts                                                                         |      100 |      100 |       50 |      100 |                   |
 cactus-cmd-api-server/src/main/typescript/cmd                                          |    29.17 |       25 |        0 |    29.17 |                   |
  cactus-api.ts                                                                         |    29.17 |       25 |        0 |    29.17 |... 32,33,35,36,41 |
 cactus-cmd-api-server/src/main/typescript/config                                       |    83.48 |    39.39 |    81.25 |    83.48 |                   |
  config-service.ts                                                                     |    85.33 |    47.83 |    83.33 |    85.33 |... 54,512,513,543 |
  convict-plugin-array-format.ts                                                        |       70 |    16.67 |       50 |       70 |           5,16,17 |
  self-signed-pki-generator.ts                                                          |    83.33 |       25 |      100 |    83.33 |    38,39,41,43,44 |
 cactus-cmd-api-server/src/main/typescript/generated/openapi/typescript-axios           |    25.45 |        0 |        0 |    26.92 |                   |
  api.ts                                                                                |    18.18 |        0 |        0 |    19.35 |... 46,157,165,185 |
  base.ts                                                                               |    38.46 |        0 |        0 |    41.67 |... 54,55,67,68,69 |
  configuration.ts                                                                      |    14.29 |        0 |        0 |    14.29 | 69,70,71,72,73,74 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
 cactus-common/src/main/typescript                                                      |     34.9 |    15.58 |    31.25 |    31.43 |                   |
  bools.ts                                                                              |       50 |        0 |        0 |       50 |                13 |
  checks.ts                                                                             |       50 |       60 |      100 |       50 |       17,18,36,37 |
  coded-error.ts                                                                        |       20 |        0 |        0 |       25 |            7,8,12 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  js-object-signer.ts                                                                   |    16.13 |        0 |        0 |    16.13 |... 99,100,101,102 |
  key-converter.ts                                                                      |    12.24 |     7.69 |    14.29 |     12.5 |... 18,121,124,125 |
  objects.ts                                                                            |     6.25 |        0 |        0 |     6.67 |... 57,58,59,60,63 |
  public-api.ts                                                                         |      100 |      100 |    27.27 |      100 |                   |
  secp256k1-keys.ts                                                                     |    42.86 |      100 |        0 |    42.86 |       17,18,22,24 |
  servers.ts                                                                            |    44.19 |    33.33 |    58.33 |       45 |... 70,92,93,96,98 |
  strings.ts                                                                            |    42.86 |        0 |    33.33 |    42.86 |       13,17,18,19 |
 cactus-common/src/main/typescript/logging                                              |    87.88 |    63.64 |    71.43 |    87.88 |                   |
  logger-provider.ts                                                                    |      100 |    71.43 |      100 |      100 |             10,27 |
  logger.ts                                                                             |    78.95 |       50 |    63.64 |    78.95 |       46,54,60,63 |
 cactus-core-api/src/main/typescript                                                    |      100 |      100 |       75 |      100 |                   |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  public-api.ts                                                                         |      100 |      100 |       75 |      100 |                   |
 cactus-core-api/src/main/typescript/generated/openapi/typescript-axios                 |    63.16 |    46.15 |       50 |    64.86 |                   |
  api.ts                                                                                |      100 |      100 |      100 |      100 |                   |
  base.ts                                                                               |    38.46 |        0 |        0 |    41.67 |... 54,55,67,68,69 |
  configuration.ts                                                                      |    14.29 |        0 |        0 |    14.29 | 69,70,71,72,73,74 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
 cactus-core-api/src/main/typescript/plugin                                             |      100 |    83.33 |      100 |      100 |                   |
  i-cactus-plugin.ts                                                                    |      100 |       75 |      100 |      100 |                85 |
  plugin-aspect.ts                                                                      |      100 |      100 |      100 |      100 |                   |
  plugin-factory.ts                                                                     |      100 |      100 |      100 |      100 |                   |
 cactus-core-api/src/main/typescript/plugin/web-service                                 |      100 |      100 |      100 |      100 |                   |
  i-plugin-web-service.ts                                                               |      100 |      100 |      100 |      100 |                   |
 cactus-core/src/main/typescript                                                        |    38.96 |    38.46 |    19.35 |    38.89 |                   |
  consortium-repository.ts                                                              |    15.79 |        0 |        0 |    16.67 |... 44,48,59,60,62 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  plugin-registry.ts                                                                    |    39.22 |    41.67 |    22.73 |    40.82 |... 22,127,132,136 |
  public-api.ts                                                                         |      100 |      100 |    33.33 |      100 |                   |
 cactus-core/src/main/typescript/web-services                                           |    11.11 |      100 |        0 |    11.11 |                   |
  register-web-service-endpoint.ts                                                      |    11.11 |      100 |        0 |    11.11 |... 18,20,21,22,24 |
 cactus-plugin-consortium-manual/src/main/typescript                                    |    30.86 |        0 |        0 |       30 |                   |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  plugin-consortium-manual.ts                                                           |    15.63 |        0 |        0 |    15.63 |... 37,141,145,149 |
  plugin-factory-consortium-manual.ts                                                   |       75 |      100 |        0 |       75 |                18 |
  public-api.ts                                                                         |    91.67 |      100 |        0 |    90.91 |                27 |
 cactus-plugin-consortium-manual/src/main/typescript/consortium                         |    13.19 |        0 |        0 |    13.33 |                   |
  get-consortium-jws-endpoint-v1.ts                                                     |    10.42 |        0 |        0 |    10.64 |... 13,114,115,116 |
  get-node-jws-endpoint-v1.ts                                                           |    16.28 |        0 |        0 |    16.28 |... 00,101,107,109 |
 cactus-plugin-consortium-manual/src/main/typescript/generated/openapi/typescript-axios |     51.9 |       36 |       40 |     52.7 |                   |
  api.ts                                                                                |    49.12 |    27.78 |    41.18 |    50.94 |... 14,222,231,262 |
  base.ts                                                                               |    76.92 |    66.67 |       50 |       75 |          67,68,69 |
  configuration.ts                                                                      |    14.29 |        0 |        0 |    14.29 | 69,70,71,72,73,74 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
 cactus-plugin-keychain-vault/src/main/typescript                                       |    50.86 |    22.22 |    20.59 |    50.43 |                   |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  plugin-factory-keychain.ts                                                            |    89.47 |    33.33 |      100 |    89.47 |             33,45 |
  plugin-keychain-vault-remote-adapter.ts                                               |     64.1 |       50 |    33.33 |     64.1 |... 27,134,138,146 |
  plugin-keychain-vault.ts                                                              |    16.33 |        0 |        0 |    16.33 |... 48,149,153,157 |
  public-api.ts                                                                         |      100 |      100 |    33.33 |      100 |                   |
 cactus-plugin-keychain-vault/src/main/typescript/generated/openapi/typescript-axios    |    77.53 |    48.98 |       65 |    78.57 |                   |
  api.ts                                                                                |    83.58 |    47.62 |    70.59 |    85.71 |... 70,228,237,247 |
  base.ts                                                                               |    76.92 |    66.67 |       50 |       75 |          67,68,69 |
  configuration.ts                                                                      |    14.29 |        0 |        0 |    14.29 | 69,70,71,72,73,74 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
 cactus-plugin-keychain-vault/src/main/typescript/web-services                          |    27.78 |        0 |        0 |    27.78 |                   |
  get-keychain-entry-endpoint-v1.ts                                                     |    27.78 |        0 |        0 |    27.78 |... 46,47,51,55,59 |
  set-keychain-entry-endpoint-v1.ts                                                     |    27.78 |        0 |        0 |    27.78 |... 46,47,51,55,59 |
 cactus-test-tooling/src/main/typescript                                                |    97.87 |        0 |    15.63 |    97.73 |                   |
  i-key-pair.ts                                                                         |       50 |        0 |        0 |       50 |                 9 |
  index.ts                                                                              |      100 |      100 |      100 |      100 |                   |
  public-api.ts                                                                         |      100 |      100 |    16.13 |      100 |                   |
 cactus-test-tooling/src/main/typescript/besu                                           |      6.8 |        0 |        0 |     6.94 |                   |
  besu-test-ledger.ts                                                                   |      6.8 |        0 |        0 |     6.94 |... 48,358,368,369 |
 cactus-test-tooling/src/main/typescript/cactus-keychain-vault-server                   |    85.11 |    68.75 |      100 |    85.11 |                   |
  cactus-keychain-vault-server.ts                                                       |    85.11 |    68.75 |      100 |    85.11 |... 06,121,122,135 |
 cactus-test-tooling/src/main/typescript/common                                         |    28.13 |    23.08 |    29.17 |    27.13 |                   |
  containers.ts                                                                         |    32.12 |    27.91 |    36.84 |    31.06 |... 92,394,395,397 |
  streams.ts                                                                            |      3.7 |        0 |        0 |      3.7 |... 65,66,68,74,75 |
 cactus-test-tooling/src/main/typescript/corda                                          |     9.15 |        0 |        0 |     9.27 |                   |
  corda-test-ledger.ts                                                                  |     8.55 |        0 |        0 |     8.67 |... 82,383,395,396 |
  sample-cordapp-enum.ts                                                                |      100 |      100 |      100 |      100 |                   |
 cactus-test-tooling/src/main/typescript/corda-connector                                |     12.5 |        0 |        0 |    12.66 |                   |
  corda-connector-container.ts                                                          |     12.5 |        0 |        0 |    12.66 |... 13,214,223,224 |
 cactus-test-tooling/src/main/typescript/fabric                                         |     7.07 |        0 |        0 |     7.14 |                   |
  fabric-test-ledger-v1.ts                                                              |     7.07 |        0 |        0 |     7.14 |... 04,505,515,516 |
 cactus-test-tooling/src/main/typescript/http-echo                                      |        8 |        0 |        0 |     8.25 |                   |
  http-echo-container.ts                                                                |        8 |        0 |        0 |     8.25 |... 23,233,242,243 |
 cactus-test-tooling/src/main/typescript/quorum                                         |     6.99 |        0 |        0 |     7.14 |                   |
  quorum-test-ledger.ts                                                                 |     6.99 |        0 |        0 |     7.14 |... 53,363,372,373 |
 cactus-test-tooling/src/main/typescript/vault-test-server                              |    82.69 |       75 |    91.67 |    82.69 |                   |
  vault-test-server.ts                                                                  |    82.69 |       75 |    91.67 |    82.69 |... 28,143,144,154 |
----------------------------------------------------------------------------------------|----------|----------|----------|----------|-------------------|
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @hyperledger/cactus@ test:integration: `tap --node-arg=--max-old-space-size=4096 --jobs=1 --timeout=600 "packages/cactus-*/src/test/typescript/integration/" "--bail"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @hyperledger/cactus@ test:integration script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-03-10T02_03_57_146Z-debug.log

Screenshots

If applicable, add screenshots to help explain your problem.

Cloud provider or hardware configuration: Are you running the software on a dev machine or somewhere in the cloud?

Operating system name, version, build:

Ubuntu 20.04 LTS

Hyperledger Cactus release version or commit (git rev-parse --short HEAD):

main

Hyperledger Cactus Plugins/Connectors Used

N/A

Additional context

This came out during the development of the Fabric contract deployment endpoint, but this fact is suspected to be a coincidence and that the issue itself has nothing to do with the Fabric connector or its tests.

cc: @takeutak @sfuji822 @hartm @jonathan-m-hamilton @AzaharaC @jordigiam @kikoncuo

petermetz commented 3 years ago

Never seen this one again since the time it was opened. Assuming to have been implicitly fixed by dependency upgrades along the way.

petermetz commented 2 years ago

Re-opening because it just popped up again, out of the blue...

logs_13945.zip

# Subtest: ./packages/cactus-cmd-api-server/src/test/typescript/unit/config/self-signed-certificate-generator/certificates-work-for-mutual-tls.test.ts
    # works with HTTPS NodeJS module
    ok 1 class present on API surface
    ok 2 Instantiated SelfSignedCertificateGenerator OK.
    ok 3 serverCert truthy
    ok 4 serverCert.certificatePem truthy
    ok 5 serverCert.privateKeyPem truthy
    ok 6 serverCert.certificate truthy
    ok 7 serverCert.keyPair truthy
    ok 8 clientCert truthy
    ok 9 clientCert.certificatePem truthy
    ok 10 clientCert.privateKeyPem truthy
    ok 11 clientCert.certificate truthy
    ok 12 clientCert.keyPair truthy
    ok 13 Server cert verified client cert OK
    ok 14 HTTPS Server object truthy
    ok 15 HTTPS Server is indeed listening
    ok 16 HTTPS Server provided truthy AddressInfo
    ok 17 HTTPS Server provided truthy AddressInfo.port
    [2022-01-21T03:16:25.071Z] DEBUG (test-generates-working-certificates): AddressInfo for test HTTPS server: {"address":"127.0.0.1","family":"IPv4","port":37883}
    not ok 18 Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
      ---
        operator: error
        at: bound (/home/runner/work/cactus/cactus/node_modules/tape-promise/node_modules/onetime/index.js:30:12)
        stack: |-
          Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
              at node:internal/tls/secure-context:65:13
              at Array.forEach (<anonymous>)
              at setCerts (node:internal/tls/secure-context:63:3)
              at configSecureContext (node:internal/tls/secure-context:152:5)
              at Object.createSecureContext (node:_tls_common:116:3)
              at Object.connect (node:_tls_wrap:1621:48)
              at Agent.createConnection (node:https:143:22)
              at Agent.createSocket (node:_http_agent:341:26)
              at Agent.addRequest (node:_http_agent:292:10)
              at new ClientRequest (node:_http_client:305:16)
      ...

    Bail out! Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
Bail out! Error: error:0D0E20DD:asn1 encoding routines:c2i_ibuf:illegal padding
petermetz commented 1 year ago

Spotted this (or something very similar) again here: 2023-08-11T21-06-36-cacti-ci-connector-fabric-socketio-illegal-padding-crash.test.log