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

Request rest API with a Certificate #63

Open
rsilvestre opened this issue Aug 28, 2015 · 3 comments
Open

Request rest API with a Certificate #63

rsilvestre opened this issue Aug 28, 2015 · 3 comments

Comments

@rsilvestre
Copy link

Hi Guys,

It's more a question than an issue, but like a face some difficulties to use certificate, i'd like to ask you how it's possible to use certificate to perform a rest request on a https server?

I'm working on the branch v0.1.0-waterline-v0.10 ?

May be you could just give me an example?

Regards

@rsilvestre rsilvestre changed the title Certificate Request rest API with a Certificate Aug 28, 2015
@zohararad
Copy link
Owner

@rsilvestre Do you mean client-side certificates? If not those, what exactly do you mean? I you provide an example? Issuing a normal HTTPS request doesn't require any particular setup.

@rsilvestre
Copy link
Author

Hi @zohararad, In the client side i have this config in the connections.js file and i try to connect on a server and i need to authenticate with a certificate :

/**
   * To contact API
   */
  listRest: {
    adapter: 'sails-rest',
    type: 'json',                   // expected response type (json | string | http)
    host: 'api.example.com',  // api host
    port: 443,                       // api port
    protocol: 'https',               // HTTP protocol (http | https)
    pathname: '/api/v1.1/public/',            // base api path
    resource: 'user',              // resource path to use (overrides model name)
    action: null,                   // action to use for the given resource ([resource]/run)
    query: function (config, collectionName, methodName, options) {

      var newOptions = {};

      if ( options.where.name ) {
        newOptions.name = options.where.name;
      }

      if ( options.limit ) {
        newOptions.itemsPerPage = options.limit;
      }

      // dont forget to pass on skip because this function is responsible for generating all the parameters
      newOptions.skip = options.skip;

      return newOptions;

    },
    headers: {
      'Accept-Language': 'fr'
    },
    methods: {                      // overrides default HTTP methods used for each CRUD action
      //create: 'post',
      find: 'get',
      //update: 'put',
      //destroy: 'del'
    }
  }

I'd like to add a certificate like that :

key: fs.readFileSync('./cert/private.key'),
cert: fs.readFileSync('./cert/certificate.crt'),

@zohararad
Copy link
Owner

@rsilvestre I see.

I'm not sure superagent (the underlying HTTP client) supports that officially. Let me take a look, but feel free to dig around yourself.

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

No branches or pull requests

2 participants