新しいBoxサポートサイトへようこそ。 変更点の詳細はこちらをご確認ください .

Problem with SSL invoking user service with Angular 4

新規投稿

コメント

2件のコメント

  • GaloM

    Well, if anyone is facing this problem, I'll explain my solution

     i reviewed the code at the point of failure

     

     Unhandled rejection Error: SSL Error: https://api.box.com/2.0/users/me does not support SSL at Request.webpackJsonp.../../../../request/request.js.Request.onRequestResponse (http://localhost:4200/vendor.bundle.js:61027:24)

    vendor.bundle.js block:

     

     

    // XXX This is different on 0.10, because SSL is strict by default
      if (self.httpModule === https &&
          self.strictSSL && (!response.hasOwnProperty('socket') ||
          !response.socket.authorized)) {
        debug('strict ssl error', self.uri.href)
        var sslErr = response.hasOwnProperty('socket') ? response.socket.authorizationError : self.uri.href + ' does not support SSL'
        self.emit('error', new Error('SSL Error: ' + sslErr))
        return
      }

    The call to Rest Service fails because strictSSL is set to true

    I tried setting the config in npm with the command:

    npm config set strict-ssl false

    but that doesn't solve the problem.

    The solution I found is modifying the configuration file in the Box NodeJS API (I was searching in the code where the value of strictSSL is determined).

    In my configuration the file is:

    /node_modules/box-node-sdk/lib/util/config.js

    Change this section:

    request: {
    		// By default, require API SSL cert to be valid
    		strictSSL: true,
    		// Use an agent with keep-alive enabled to avoid performing SSL handshake per connection
    		agentClass: https.Agent,
    		agentOptions: {
    			keepAlive: true
    		},
    		// Encode requests as JSON. Encode the response as well if JSON is returned.
    		json: true,
    		// Do not encode the response as a string, since the response could be a file. return Buffers instead.
    		encoding: null,
    		// A redirect is usually information we want to handle, so don't automatically follow
    		followRedirect: false,
    		// By default, we attach a version-specific user-agent string to SDK requests
    		headers: {
    			'User-Agent': 'Box Node.js SDK v' + version
    		}
    	}

    to this:

    request: {
    		// By default, require API SSL cert to be valid
    		strictSSL: false,
    		// Use an agent with keep-alive enabled to avoid performing SSL handshake per connection
    		agentClass: https.Agent,
    		agentOptions: {
    			keepAlive: true
    		},
    		// Encode requests as JSON. Encode the response as well if JSON is returned.
    		json: true,
    		// Do not encode the response as a string, since the response could be a file. return Buffers instead.
    		encoding: null,
    		// A redirect is usually information we want to handle, so don't automatically follow
    		followRedirect: false,
    		// By default, we attach a version-specific user-agent string to SDK requests
    		headers: {
    			'User-Agent': 'Box Node.js SDK v' + version
    		}
    	}

    that is, switch strictSSL value from true to false

    Now it works 🙂

     

    0
    コメントアクション パーマリンク
  • GaloM

    Finally I have some doubts...

    I'm not sure if this is designed this way. Shall I modify Box API source code?

    ¿Why does Box NodeJS API fail to consume their own Rest Service?

    Is this a bug?

    0
    コメントアクション パーマリンク

サインインしてコメントを残してください。