alexa-js / alexa-app-server

An Alexa app server for alexa-app.
MIT License
401 stars 116 forks source link

missing certificate url #90

Open pgbladeqcode opened 7 years ago

pgbladeqcode commented 7 years ago

Hi,

every i time i start my server i get the following error: {"status":"failure","reason":"missing certificate url"}

I tried it with a self signed certificat and altough with an existing wildcard certificat from my domain. Whats wrong there ?

I've tried altough the old version 2.3.1 (as mentioned in another issue) , but i get the same error.

Here are my settings:

var AlexaAppServer = require("alexa-app-server");

AlexaAppServer.start({
  server_root: __dirname,
  port: 83,
  debug:false,
  verify:true,
  log : true,
  // Use preRequest to load user data on each request and add it to the request json.
  // In reality, this data would come from a db or files, etc.
  preRequest: function(json, req, res) {
    console.log("preRequest fired");
    json.userDetails = { "name": "Bob Smith" };
  },
  // Add a dummy attribute to the response
  postRequest: function(json, req, res) {
    console.log("JKO");
    json.dummy = "text";
  },

    httpsEnabled: true,

    // The https port the server will bind to. Required for httpsEnabled support.
    // Default is undefined.
    httpsPort: 8181,

    // The private key filename. This file must reside in the sslcert folder under the
    // root of the project. Default is undefined.
    privateKey: 'key.key',

    // The certificate filename. This file must reside in the sslcert folder under the root of the
    // project. Default is undefined.
    certificate: 'crt.crt',

    bundle: 'ca.crt'
});
dblock commented 7 years ago

Do you get this error when you make a manual request or one from the alexa test UI or an actual device?

This error comes from alexa-verifier, that means the request is missing the URL, not the server. When you enable verify: true in the configuration above it will ensure that the request comes form the alexa platform. For development set it to false.

Does this help?

pgbladeqcode commented 7 years ago

Hey thanks for your answer. It's working with "verify:false", but it should work with my Amazon Developer Console , so i switch the parameter to true. (Manuel request say:{"status":"failure","reason":"missing certificate url"})

Whatever i do with my developer console at amazon i get this error "The remote endpoint could not be called, or the response it returned was invalid." .. but i can call the domain from all devices / smartphones etc.. with no SSL - Error or something. Thanks !

dblock commented 7 years ago

Can you curl your SSL endpoint successfully with SSL enabled with your certificate and verify: true?

dblock commented 7 years ago

Have you uploaded the self-signed certificate to AWS? See https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/testing-an-alexa-skill#testing-a-web-service under "SSL Certificate":

SSL Certificate: Select one of the options. If you want to use a self-signed SSL certificate for testing, create that certificate and upload it to the Developer Portal. See Configuring Your Web Service to Use a Self-Signed Certificate.

Once you get it working, maybe contribute a note to the README, this wasn't clear for me when I re-read it.

pgbladeqcode commented 7 years ago

Yes i can do it with a REST Tool or with the browser successfully. It's not a self signed certificate ... :( It's a wildcard SSL

dblock commented 7 years ago

Anything in the server-side logs? Do you see the request actually making it through? Maybe another error?

Assuming the skill works without SSL from the amazon test tools, the problem must be SSL / the certificate.

So I would check with a few browsers/curl in case there's some kind of warning about the certificate (eg. an intermediate certificate is not present), and then I am out of ideas, I would ask an Amazon forum.

pgbladeqcode commented 7 years ago

Thank you ! .. It won't work from amazon, only from "manuel calling" the Server (SSL/NON-SSL)... Is there a way to create an access log for AlexaAppServer ? So i can log the connections to the server ? Thanks

dblock commented 7 years ago

It depends how/where you deploy your alexa-app-server, but you should be seeing the same express log as you see locally.

pgbladeqcode commented 7 years ago

The problem is, if i use an alexa app eg. https://xxxx:8181/alexa/hello_world i get no response (locally / amazon) in the server console, maybe its a problem with the port 8181 ? .. :(

Update: I tried it on an AWS Virtual machine .. works .. (not lambda, debian VPS) But only with Port 443 .. Maybe there is the issue ?!

Update 2: Works fine with port 443 locally... very strange !

ericblade commented 7 years ago

Perhaps the Alexa end-point doesn't support port specifier? Or you have a firewall blocking ?

Here's a little snippet that I use to make sure that I can see what's going on on my server:

// simple request url logger

module.exports = (express, alexaAppServer) => {
    express.use('/', (req, res, next) => {
        if (req.connection.ssl) {
            console.warn('**** server: ssl request', req.url);
            next();
        } else {
            console.warn('**** server: non-ssl request', req.url);
            next();
        }
    });
};

I put this in the directory that is specified by server_dir