pycom / pycom-libraries

MicroPython libraries and examples that work out of the box on Pycom's IoT modules
330 stars 379 forks source link

Using genkey.sh on google iot core example does not work #118

Open netskink opened 4 years ago

netskink commented 4 years ago

Using the genkey.sh script to create a key does not work. The generated .pem file will fail when you try to add to the Google Cloud console IOT Core Registry CA certificate will say "Certificate is in an invalid PEM format."

What are th.e steps to reproduce this issue?

  1. Recreate the file system for the pycom-libraries/GoogleIOT example
  2. Cd to pycom-libraries/GoogleIOT/
  3. ./genkey.sh some-name
  4. In google cloud console navigate to hamburger menu on upper left->BigData->Iot Core->my registry
  5. Click registry entry name for details
  6. Click CA Certificates
  7. Click Add certificates
  8. Click upload
  9. Browse to db/ and select the public .pem file.
  10. click ok

Also tried to modify flash/config.example.py to have valid project id and did above. It had same result.

What happens?

The generated .pem file will fail when you try to add to the Google Cloud console IOT Core Registry CA certificate will say "Certificate is in an invalid PEM format."

What were you expecting to happen?

I was expecting the CA certificate to be added.

Any logs, error output, etc?

davis@twenty:~/progs/pycom-testy/iot2$ ./genkey.sh lopy4
Generating RSA private key, 2048 bit long modulus (2 primes)
....................+++++
..........................................+++++
e is 65537 (0x010001)
writing RSA key
--2020-04-24 16:05:06--  https://pki.google.com/roots.pem
Resolving pki.google.com (pki.google.com)... 74.125.196.102, 74.125.196.100, 74.125.196.101, ...
Connecting to pki.google.com (pki.google.com)|74.125.196.102|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 76276 (74K) [application/x-pem-file]
Saving to: ‘flash/cert/google_roots.pem’

flash/cert/google_roots.pem        100%[===============================================================>]  74.49K  --.-KB/s    in 0.06s   

2020-04-24 16:05:06 (1.30 MB/s) - ‘flash/cert/google_roots.pem’ saved [76276/76276]

Please add this public key to Google Cloud IoT Core Registry
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAv16a3gbqtKS3Z6uCxI2K
66La1Nr3hDZpJTtqc0NU5ok6m9ljENqhBDHASmxwn3aKI8HryyWekmn0f7S9/QU0
oOmyCPQ6Q8AsLl/0qMoC2C9bUh8aphqlLlEooPA3D/cHkpIEZjgH1CNYiENChQZC
natc8YYSb4yOZCYSc9irsf+y1OcV47X/5qwb0eMgI4Vqcp02m+NQMIJFgGtfI0Ca
fPmUyY+Hmz88zLce6N3Sc7WPyfKEF3ilwtHw/xiWZ4Y1bREkAbZ5jma0XUYOyKed
5VPOxaGeFvOR7DMjFZRfuG7VPoBZ+oP21DZldLrTwUY56Z0Esj10emK0ZoMEOuy/
4QIDAQAB
-----END PUBLIC KEY-----

Any other comments?

I had a similar problem using the official google repo version of this file. I was able to get a cert to upload there. Here is the issue. https://github.com/GoogleCloudPlatform/iot-core-micropython/issues/10

What versions of software are you using?