Repository: certbot/certbot

Issue:
acme sends wrong content-type when retrieving certificate
When acme retrieves the finished certificate from a v2 server, it sends the wrong Content-Type in the POST-as-GET request.

From the log:
```
2019-02-10 14:09:56,254 - DEBUG - Storing nonce: MEkucy-acRGA4hwbU1PJOrs8vDyji61HII51zrDtM08
2019-02-10 14:09:56,254 - DEBUG - JWS payload:
b''
2019-02-10 14:09:56,262 - DEBUG - Sending POST request to https://acme-staging-v02.api.letsencrypt.org/acme/cert/XX:
{
  "protected": "XXX",
  "signature": "ED9p8G75Tqgj3suG7XY1d4GrnKU6dl76_O-0O9B8KP7SbdyaURHkwr-ITukDDWXkpbdwXG-COFuLUvRFY3N_OWWHoo-OMyOiAJPSLScoWK87e6Ek81qJbIAMeLYDiGZz261Z6GjItBogsCj_xthIoCI7LJnx_Z6rEmWcPiMAvmmjrhD9IMPeCvtWR
6q-xl84YfNFzkNWdiqGkC-aYHMoDQEZTPrUyzRJ_tCkb7kSP01Dl0MM94Xz-kEbsRB3Lm-o267YIMFrQF5rxDoLvA7_7i2RWnfueFcSDZBl2iZTyE40oJa2Jrjq9Sn_qKZVjRPUCFM6Y2sTOm-_4ICt1wHk2I17xwervrDemmHM_L8EZCfN1WoS1jAIlMGG3vvOgO8Z8W
JwUwNdxafQfZq0NryzaEk84w3PodiQYwO59BTR5d1MxS3wSLF8JieX74OW6qaiHbBdBy0E6G6vlybx9zNnH2tNU-5mx6QMntCBsBd-9nZw_t9srGhUAOG4TUGZiq3nIRDE6Ccpx2JgnM_LjWLTXTJ1iZ15-FBZEVSlA3rNc1N4-vHk8fLlW0r7PEryoJ_TRg0jPjvja1I
wuERBRMWNhBaiquS2WLJKwhSmHjmOQIMmBHHFDARY-z3bsDkzvYer_C_IXFWhghGDf1ANbUFOtqoNqGSaQBNws1_DA2a1LFU",
  "payload": ""
}
2019-02-10 14:09:56,650 - DEBUG - Received response:
HTTP 415
Server: nginx
Content-Type: application/problem+json
Content-Length: 168
Replay-Nonce: kO9ju1BGrUiUd7QJlkUFZnqDBBUa60rdUJSdprVRA_0
Expires: Sun, 10 Feb 2019 13:09:56 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Sun, 10 Feb 2019 13:09:56 GMT
Connection: close

{
  "type": "urn:ietf:params:acme:error:malformed",
  "detail": "Invalid Content-Type header on POST. Content-Type must be \"application/jose+json\"",
  "status": 415
}
2019-02-10 14:09:56,651 - DEBUG - Error during a POST-as-GET request, your ACME CA may not support it:
urn:ietf:params:acme:error:malformed :: The request message was malformed :: Invalid Content-Type header on POST. Content-Type must be "application/jose+json"
2019-02-10 14:09:56,651 - DEBUG - Retrying request with GET.
2019-02-10 14:09:56,651 - DEBUG - Sending GET request to https://acme-staging-v02.api.letsencrypt.org/acme/cert/XXx.
2019-02-10 14:09:59,520 - DEBUG - Received response:
HTTP 200
Server: nginx
Content-Type: application/pem-certificate-chain
```

Looking at the request, the Content-Type is `application/pkix-cert` instead of `application/jose+json`.


Discussion:

Resolving patch:
diff --git a/acme/acme/client.py b/acme/acme/client.py
--- a/acme/acme/client.py
+++ b/acme/acme/client.py
@@ -739,8 +739,7 @@ def finalize_order(self, orderr, deadline):
             if body.error is not None:
                 raise errors.IssuanceError(body.error)
             if body.certificate is not None:
-                certificate_response = self._post_as_get(body.certificate,
-                                                    content_type=DER_CONTENT_TYPE).text
+                certificate_response = self._post_as_get(body.certificate).text
                 return orderr.update(body=body, fullchain_pem=certificate_response)
         raise errors.TimeoutError()
 


Test patch: