binance / binance-connector-typescript

Simple Typescript connector to Binance API
MIT License
63 stars 29 forks source link

🐞 ERR_OSSL_UNSUPPORTED Error When Calling Spot.newOrder and Spot.testNewOrder Methods🐞 #15

Open oviniciusfeitosa opened 8 months ago

oviniciusfeitosa commented 8 months ago

Problem Description: I am encountering an ERR_OSSL_UNSUPPORTED error when calling the Spot.newOrder and Spot.testNewOrder methods from the @binance/connector-typescript library. The error occurs both when starting the application with the command NODE_OPTIONS='--openssl-legacy-provider' node --experimental-specifier-resolution=node --loader ./loader.mjs src/Api.ts and with the command node --experimental-specifier-resolution=node --loader ./loader.mjs src/Api.ts.

The ERR_OSSL_UNSUPPORTED error typically indicates that OpenSSL is trying to use an algorithm or key size that is no longer allowed by default with OpenSSL 3.0. This can occur when you are using a newer version of Node.js that includes OpenSSL 3.0, but the code or modules you are using were written for an older version of OpenSSL.

Environment:

List of libraries and versions used by pnpm:

{ npm: β€˜10.2.4’, node: β€˜20.11.0’, acorn: β€˜8.11.2’, ada: β€˜2.7.4’, ares: β€˜1.20.1’, base64: β€˜0.5.1’, brotli: β€˜1.0.9’, cjs_module_lexer: β€˜1.2.2’, cldr: β€˜43.1’, icu: β€˜73.2’, llhttp: β€˜8.1.1’, modules: β€˜115’, napi: β€˜9’, nghttp2: β€˜1.58.0’, nghttp3: β€˜0.7.0’, ngtcp2: β€˜0.8.1’, openssl: β€˜3.0.12+quic’, simdutf: β€˜4.0.4’, tz: β€˜2023c’, undici: β€˜5.27.2’, unicode: β€˜15.0’, uv: β€˜1.46.0’, uvwasi: β€˜0.0.19’, v8: β€˜11.3.244.8-node.17’, zlib: β€˜1.2.13.1-motley-5daffc7’ }

package.json

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@binance/connector-typescript": "^0.3.6",
    "@types/node": "^16.18.82",
    "axios": "^1.6.5",
    "bignumber.js": "^9.1.2",
    "cors": "^2.8.5",
    "crypto-js": "^4.2.0",
    "dotenv": "^16.3.1",
    "express": "^4.18.2"
  },
  "scripts": {
    "server": "NODE_OPTIONS='--openssl-legacy-provider' node --experimental-specifier-resolution=node --loader ./loader.mjs src/Api.ts ",
    "server-win": "ts-node-esm --project tsconfig.json src/Server.ts",
    "server-config": "NODE_OPTIONS='--loader ts-node/esm' ts-node --showConfig"
  },
  "devDependencies": {
    "@types/cors": "^2.8.17",
    "@types/express": "^4.17.21",
    "ts-node": "^10.9.2",
    "tslib": "^2.6.2",
    "typescript": "^5.3.3"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": ".",
    "module": "ESNext",
    "esModuleInterop": true,
    "target": "ESNext",
    "moduleResolution": "node",
    "outDir": "dist",
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "isolatedModules": false,
    "strict": true,
    "noImplicitAny": true,
    "useUnknownInCatchVariables": false,
    "inlineSourceMap": true,
    "lib": ["ESNext","ESNext.BigInt"],
    "types": ["node"],
    "typeRoots": ["node_modules/@types"]
  },
  "ts-node": {
    "esm": true,
    "files": true,
  },
  "lib": ["esnext"],
  "include": ["src/*.ts", "src/*.json", ".env"],
  "exclude": ["node_modules", "src/http", "src/logs"]
}

Error Details: The full error is as follows:

Error: error:1E08010C:DECODER routines::unsupported 
at Object.signOneShot (node:internal/crypto/sig:163:15) at Spot.prepareSignedPath (/opt/test/node_modules/.pnpm/@binance+connector-typescript@0.3.6/node_modules/@binance/connector-typescript/dist/index.js:5057:27) 
at Spot.newOrder (/opt/test/node_modules/.pnpm/@binance+connector-typescript@0.3.6/node_modules/@binance/connector-typescript/dist/index.js:3058:24) 
at executeTradeTrade (file:///opt/test/src/tools/BinanceTools.ts:158:42) 
at executeTradeOpportunity (file:///opt/test/src/components/Trade.ts:140:30) 
at file:///opt/test/src/Api.ts:74:34 at Layer.handle [as handle_request] (/opt/test/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/layer.js:95:5) 
at next (/opt/test/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:144:13) 
at Route.dispatch (/opt/test/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/route.js:114:3) 
at Layer.handle [as handle_request] (/opt/test/node_modules/.pnpm/express@4.18.2/node_modules/express/lib/router/layer.js:95:5) 
{ library: β€˜DECODER routines’, reason: β€˜unsupported’, code: β€˜ERR_OSSL_UNSUPPORTED’ }

Any help in resolving this issue would be greatly appreciated.

oviniciusfeitosa commented 8 months ago

Additional Attempts to Start the Application:

I have also tried other ways to start the application, but they all resulted in the same ERR_OSSL_UNSUPPORTED error.

  1. Using ts-node directly: I tried running the application with ts-node directly using the command ts-node src/Api.ts, but the error still occurred.

  2. Without the --openssl-legacy-provider option: I tried starting the application without the --openssl-legacy-provider option using the command node --experimental-specifier-resolution=node --loader ./loader.mjs src/Api.ts, but the error persisted.

  3. With different Node.js versions: I also tried using different versions of Node.js, but none of them resolved the issue.

It seems that no matter how I try to start the application, the ERR_OSSL_UNSUPPORTED error always occurs when calling the Spot.newOrder and Spot.testNewOrder methods from the @binance/connector-typescript library. Any insights or suggestions would be greatly appreciated.

zhaoyangnk commented 6 months ago

+1