2

I'm trying to setup a private Certificate Authority (CA) in AWS ACM in order to setup a direct VPN connection to a VPC without internet access (on purpose). https://docs.aws.amazon.com/vpn/latest/clientvpn-admin/cvpn-getting-started.html

So in the VPN Client configuration I need to get the Server certificate ARN. That's where I've gone to try and setup the private CA in order to setup the Client VPN Endpoint.

Currently, I've created the Private CA in ACM, but need to:

Import a CA certificate to activate your CA.

I'm a little unclear on what's going on here. At the moment it's just me, so I've done the following:

(Following this link: https://gist.github.com/fntlnz/cf14feb5a46b2eda428e000157447309 )

On Local PC:

  1. Create root CA Private Key:

    openssl genrsa -des3 -out rootCA.key 4096
    
  2. Create and self-sign the "Root Certificate" on local pc:

    openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
    
    1. Generate the certificate for AWS service, "AWS Service Certificate", with CA Root key(Private Key)/Root Certificate and the AWS issued CSR:
    openssl x509 -req -in AWS-PRIVATE-CSR.pem -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out service.aws.crt -days 500 -sha256
    

Then from the AWS ACM Console:

  1. From the Import CA Certificate dialog:

    • Add "AWS Service Certificate" as the Certificate body
    • Add "Root Certificate" as the Certificate chain

At this point I get the error when I click, "Confirm and Import":

CertificateMismatchException The certificate version must be greater than or equal to 3.

I checked the version of the generated, "AWS Service Certificate" with t he the following command, and it shows as Version 1.

openssl x509 -in service.aws.crt -text -noout
Certificate:
    Data:
        Version: 1 (0x0)
        Serial Number:
    ...

So apparently I'm doing something wrong here, but I can't seem to find what it is. To resolve the current AWS error my question is:

  • How can I generate a Version: 3 cert using the root Key/Cert and AWS CSR?

Alternatively what's the best way to connect to a VPC without internet access? If it's easier to setup a VPC<->VPC connection where I can access the other VPC via SSH that could work.

monkut
  • 42,176
  • 24
  • 124
  • 155
  • You must either have a very old version of openssl or have some weird openssl config setup. It should generate v3 certificates and has done for a very long time now... – Shane Powell May 24 '19 at 01:15
  • Ok, I'll check. The interesting thing is that the generated `root certificate` is generated as version 3. I noticed that one uses the `req` command resulting in version 3, while the CSR certificate command `x509` is used, resulting in version 1.... – monkut May 24 '19 at 02:48
  • OpenSSL 1.1.0g 2 Nov 2017 – monkut May 24 '19 at 02:51
  • upgrading version with procedure here https://askubuntu.com/questions/1102803/how-to-upgrade-openssl-1-1-0-to-1-1-1-in-ubuntu-18-04 – monkut May 24 '19 at 02:55

1 Answers1

2

I was incorrect in my comment that it may be your openssl version. The instructions are a little off on generating the certificate from the CSR. The problem is that you don't have openssl setup correctly to do this.

The easiest fix is to create a text file (e.g. v3.ext) with the contents of:

authorityKeyIdentifier=keyid,issuer
basicConstraints=critical,CA:TRUE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment

The add the following to your openssl command line "-extfile filename" e.g. "-extfile v3.ext"

So your openssl command will be:

openssl x509 -req -in AWS-PRIVATE-CSR.pem -CA rootCA.crt -CAkey rootCA.key -CAcreateserial -out service.aws.crt -days 500 -sha256 -extfile v3.ext

You can then verify with

openssl x509 -in service.aws.crt -text -noout

That should generate you a v3 certificate.

monkut
  • 42,176
  • 24
  • 124
  • 155
Shane Powell
  • 13,698
  • 2
  • 49
  • 61
  • beautiful! Yes, I've confirm that this gives me a v3 Certificate! – monkut May 24 '19 at 04:21
  • At this this got me to the next error: `The basic constraints extension must specify that the certificate is for a CA.` – monkut May 24 '19 at 04:29
  • Updated the following line in the `v3.ext` file created that you mentioned the cert import successfully: `basicConstraints=critical,CA:TRUE` – monkut May 24 '19 at 04:34