f5-appsvcs-extension icon indicating copy to clipboard operation
f5-appsvcs-extension copied to clipboard

PCKS12 cert not able to be referenced

Open timothyfranson opened this issue 5 years ago • 9 comments
trafficstars

Environment

  • Application Services Version: 3.20.0
  • BIG-IP Version: 15.0.1

Summary

A PCKS12 (.pfx) cert added via AS3 is not able to be referenced.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Submit the following declaration:
{
    "class": "ADC",
    "schemaVersion": "3.20.0",
    "id": "test",
    "test": {
        "class": "Tenant",
        "Shared": {
            "class": "Application",
            "template": "shared",
            "service": {
                "class": "Service_HTTPS",
                "virtualAddresses": [
                    "10.0.1.186"
                ],
                "clientTLS": "tlsClient",
                "serverTLS": "tlsServer",
                "virtualPort": 443
            },
            "tlsServer": {
                "class": "TLS_Server",
                "certificates": [
                    {
                        "certificate": "cert"
                    }
                ]
            },
            "tlsClient": {
                "class": "TLS_Client",
                "forwardProxyEnabled": true
            },
            "cert": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "<BASE64_ENCODED_PASSPHRASE>",
                    "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJub25lIn0",
                    "ignoreChanges": true
                },
                "pkcs12": {
                    "base64": "<BASE64_ENCODED_FILE>"
                }
            }
        }
    }
}
  1. Observe the following error response:
{
    "code": 422,
    "message":"java.net.ProtocolException: status:422, body:{\"results\":[{\"code\":422,\"message\":\"declaration failed\",\"response\":\"01070277:3: The requested certificate (/test/Shared/cert.crt) was not found.\",\"host\":\"localhost\",\"tenant\":\"test\",\"runTime\":2663}],\"declaration\":{\"test\":{\"class\":\"Tenant\",\"Shared\":{\"class\":\"Application\",\"template\":\"shared\",\"cert\":{\"class\":\"Certificate\",\"passphrase\":{\"ciphertext\":\"<SANITIZED>\",\"protected\":\"eyJhbGciOiJkaXIiLCJlbmMiOiJmNXN2In0=\",\"ignoreChanges\":true,\"miniJWE\":true},\"pkcs12\":{\"base64\":\"<SANITIZED>

Expected Behavior

All objects should be created

Actual Behavior

I get the above error. The issue is not the cert either - if I water the declaration down to only the cert it gets imported without issue.

timothyfranson avatar Jun 18 '20 22:06 timothyfranson

Thank you for reporting this bug. I have confirmed the bug and added it to our internal product backlog as AUTOTOOL-1665.

dstokesf5 avatar Jun 19 '20 16:06 dstokesf5

It looks like when I reproduced this bug, I mistook a similar error message for the one being reported here. I received an error because the pkcs12 data I was using did not contain a key. We have been unable to reproduce this with valid pkcs12 data. Have you confirmed that both a certificate and key are present in your pkcs12 data?

dstokesf5 avatar Jul 10 '20 17:07 dstokesf5

Yes. And to reiterate, if I remove the 'tlsServer' section of the above declaration, the certs and key get imported just fine. See below for error vs good declaration (watered it down even more here). When I login after applying the good declaration I can see the cert and key imported just as they should. I can even at this point manually create an SSL profile referencing it.

Also, I don't know if it makes a difference but I'm doing this against LTMs in Azure.

Errored declaration:

{
    "class": "ADC",
    "schemaVersion": "3.20.0",
    "id": "test",
    "test": {
        "class": "Tenant",
        "Shared": {
            "class": "Application",
            "template": "shared",
            "tlsServer": {
                "class": "TLS_Server",
                "certificates": [
                    {
                        "certificate": "cert"
                    }
                ]
            },
            "cert": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "SANITIZED",
                    "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJub25lIn0",
                    "ignoreChanges": true
                },
                "pkcs12": {
                    "base64": "SANITIZED"
                }
            }
        }
    }
}

Errored response:

{
    "results": [
        {
            "code": 422,
            "message": "declaration failed",
            "response": "01070277:3: The requested certificate (/test/Shared/cert.crt) was not found.",
            "host": "localhost",
            "tenant": "test",
            "runTime": 2654
        }
    ],
    "declaration": {
        "class": "ADC",
        "schemaVersion": "3.20.0",
        "id": "test",
        "updateMode": "selective",
        "controls": {
            "archiveTimestamp": "2020-07-23T18:20:05.050Z"
        }
    },
    "code": 422
}

Good declaration:

{
    "class": "ADC",
    "schemaVersion": "3.20.0",
    "id": "test",
    "test": {
        "class": "Tenant",
        "Shared": {
            "class": "Application",
            "template": "shared",
            "cert": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "SANITIZED",
                    "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJub25lIn0",
                    "ignoreChanges": true
                },
                "pkcs12": {
                    "base64": "SANITIZED"
                }
            }
        }
    }
}

Good Response:

{
    "results": [
        {
            "code": 200,
            "message": "success",
            "lineCount": 22,
            "host": "localhost",
            "tenant": "test",
            "runTime": 2566
        }
    ],
    "declaration": {
        "class": "ADC",
        "schemaVersion": "3.20.0",
        "id": "test",
        "test": {
            "class": "Tenant",
            "Shared": {
                "class": "Application",
                "template": "shared",
                "cert": {
                    "class": "Certificate",
                    "passphrase": {
                        "ciphertext": "SANITIZED",
                        "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJmNXN2In0=",
                        "ignoreChanges": true,
                        "miniJWE": true
                    },
                    "pkcs12": {
                        "base64": "SANITIZED"
                    }
                }
            }
        },
        "updateMode": "selective",
        "controls": {
            "archiveTimestamp": "2020-07-23T18:21:03.550Z"
        }
    }
}

timothyfranson avatar Jul 23 '20 18:07 timothyfranson

I'll also note that since opening this ticket, I've burned down the LTM I originally tested this on, and rebuilt it on code 15.1.0.2, my previous comment was run against this new code version (though the error is pretty much the same). AS3 version is still the same.

timothyfranson avatar Jul 23 '20 18:07 timothyfranson

I generated a certificate, key, and a combined pkcs12 file with a passphrase of "password". I then used those successfully in the simple declaration below. I believe something is wrong with your pkcs12 input.

{
    "class": "ADC",
    "schemaVersion": "3.20.0",
    "id": "test",
    "test": {
        "class": "Tenant",
        "Shared": {
            "class": "Application",
            "template": "shared",
            "tlsServer": {
                "class": "TLS_Server",
                "certificates": [
                    {
                        "certificate": "cert"
                    }
                ]
            },
            "cert": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "cGFzc3dvcmQ="
                },
                "pkcs12": {
                    "base64": "MIIQMQIBAzCCD/cGCSqGSIb3DQEHAaCCD+gEgg/kMIIP4DCCBg8GCSqGSIb3DQEHBqCCBgAwggX8AgEAMIIF9QYJKoZIhvcNAQcBMBwGCi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ZdJ686csfB1K0I+w6RoSSjhJwQI5sGfknY7DUwCAggA"
                }
            }
        }
    }
}

dstokesf5 avatar Nov 11 '20 19:11 dstokesf5

Closing this issue for inactivity.

dstokesf5 avatar Dec 01 '20 18:12 dstokesf5

I'd like to reopen this issue as i faced the same problem.

copy of what @timothyfranson said :

"And to reiterate, if I remove the 'tlsServer' section of the above declaration, the certs and key get imported just fine. See below for error vs good declaration (watered it down even more here). When I login after applying the good declaration I can see the cert and key imported just as they should. I can even at this point manually create an SSL profile referencing it."

P12 bundle that I use works fine (i can use them on my windows, i can use them in BIGIP manually). But as soon as I try to implement them using AS3, I've got the message The requested certificate (/partition/application/webcrt.crt) was not found."

as3 declaration that works :

{
    "class": "ADC",
    "schemaVersion": "3.25.0",
    "Partition": {
        "class": "Tenant",
        "Application": {
            "class": "Application",
            "WEBCRT": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "****"
                },
                "pkcs12": {
                    "base64": "****"
                }
            }
        }
    }
}

as3 declaration that doesn't works :

{
    "class": "ADC",
    "schemaVersion": "3.25.0",
    "Partition": {
        "class": "Tenant",
        "Application": {
            "class": "Application",
            "WEBTLS": {
                "class": "TLS_Server",
                "certificates": [
                    {
                        "certificate": "cert"
                    }
                ]
            },
            "WEBCRT": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "****"
                },
                "pkcs12": {
                    "base64": "****"
                }
            }
        }
    }
}

BenEkpy avatar Feb 10 '21 17:02 BenEkpy

Please re-open as this issue as it is still unresolved. When you import a PKCS12 certificate and key, the key is named correctly, but the certificate is not. AS3 does not append the .crt to the certificate file, so it cannot be referenced in a SSL profile configuration.

{
  "class": "AS3",
  "action": "deploy",
  "persist": true,
  "declaration": {
    "CertTest": {
        "class": "Tenant",
        "test": {
            "class": "Application",
            "example_cert": {
                "class": "Certificate",
                "passphrase": {
                    "ciphertext": "IA==",
                    "protected": "eyJhbGciOiJkaXIiLCJlbmMiOiJub25lIn0"
                },
                "pkcs12": {
                    "url": {
                        "url": "https://gitea.example/certificateStore/raw/branch/master/example_092621.p12",
                        "skipCertificateCheck": true
                    }
                }
            },
            "example_cert_clientssl": {
                "class": "TLS_Server",
                "certificates": [
                    {
                        "certificate": "example_cert"
                    }
                ]
            }           
        }
 
    },
    "class": "ADC",
    "schemaVersion": "3.30.0"
  }
}
Tue, 09 Nov 2021 13:20:59 GMT - severe: [appsvcs] {"message":"Declaration failed: 01070277:3: The requested certificate (/CertTest/test/example_cert.crt) was not found.","level":"error"}

root@(bigTest01)(cfg-sync Standalone)(Active)(/CertTest/test)(tmos)# show sys crypto cert all
1 certificates found
sys crypto cert example_cert {
    certificate-status none
    ocsp-status none
}

as you can see the .crt fro the example_cert is missing.

ajgerace avatar Nov 09 '21 19:11 ajgerace

Thank you for adding additional information to this issue. I have re-opened it and flagged it for triage.

dstokesf5 avatar Nov 09 '21 19:11 dstokesf5