{"action":"created","issue":{"url":"https://api.github.com/repos/r509/r509-ca-http/issues/38","repository_url":"https://api.github.com/repos/r509/r509-ca-http","labels_url":"https://api.github.com/repos/r509/r509-ca-http/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/r509/r509-ca-http/issues/38/comments","events_url":"https://api.github.com/repos/r509/r509-ca-http/issues/38/events","html_url":"https://github.com/r509/r509-ca-http/issues/38","id":183263665,"number":38,"title":"Help with API and curl","user":{"login":"rjes","id":6592809,"avatar_url":"https://avatars.githubusercontent.com/u/6592809?v=3","gravatar_id":"","url":"https://api.github.com/users/rjes","html_url":"https://github.com/rjes","followers_url":"https://api.github.com/users/rjes/followers","following_url":"https://api.github.com/users/rjes/following{/other_user}","gists_url":"https://api.github.com/users/rjes/gists{/gist_id}","starred_url":"https://api.github.com/users/rjes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjes/subscriptions","organizations_url":"https://api.github.com/users/rjes/orgs","repos_url":"https://api.github.com/users/rjes/repos","events_url":"https://api.github.com/users/rjes/events{/privacy}","received_events_url":"https://api.github.com/users/rjes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-16T12:06:37Z","updated_at":"2016-10-16T19:28:06Z","closed_at":null,"body":"Hello!\r\nI'm trying to issue a certificate with curl:\r\n```\r\n$ openssl req -nodes -newkey rsa:2048 -keyout test-cert.key -out test-cert.csr -subj \"/C=SE/ST=Stockholm/L=Stockholm/O=Netnerdz/OU=CA-App/CN=test-cert\"\r\nGenerating a 2048 bit RSA private key\r\n....+++\r\n.........................................................................+++\r\nwriting new private key to 'test-cert.key'\r\n-----\r\n$ curl -XPOST -v -d \"subject[C]=SE&subject[ST]=Stockholm&subject[L]=Stockholm&subject[O]=Netnerdz&subject[OU]=CA-App&subject[CN]=test-cert&ca=ca-app.netnerdz.se&profile=server&validityPeriod=31536000&csr=$(cat test-cert.csr | grep -v -- '----')\" 172.20.202.20:9292/1/certificate/issue\r\n*   Trying 127.0.0.1...\r\n* TCP_NODELAY set\r\n* Connected to 127.0.0.1 (127.0.0.1) port 10081 (#0)\r\n> POST /1/certificate/issue HTTP/1.1\r\n> Host: 172.20.202.20:9292\r\n> User-Agent: curl/7.50.3\r\n> Accept: */*\r\n> Content-Length: 1125\r\n> Content-Type: application/x-www-form-urlencoded\r\n> Expect: 100-continue\r\n> \r\n* Done waiting for 100-continue\r\n* We are completely uploaded and fine\r\n< HTTP/1.1 500 Internal Server Error \r\n< Content-Type: text/plain;charset=utf-8\r\n< Content-Length: 49\r\n< Server: WEBrick/1.3.1 (Ruby/2.3.1/2016-04-26)\r\n< Date: Sun, 16 Oct 2016 12:04:49 GMT\r\n< Connection: Keep-Alive\r\n< \r\n* Curl_http_done: called premature == 0\r\n* Connection #0 to host 172.20.202.20 left intact\r\n#<OpenSSL::X509::RequestError: nested asn1 error>\r\n$ \r\n```\r\nAny clue how to fix this?\r\n//Robert"},"comment":{"url":"https://api.github.com/repos/r509/r509-ca-http/issues/comments/254068362","html_url":"https://github.com/r509/r509-ca-http/issues/38#issuecomment-254068362","issue_url":"https://api.github.com/repos/r509/r509-ca-http/issues/38","id":254068362,"user":{"login":"rjes","id":6592809,"avatar_url":"https://avatars.githubusercontent.com/u/6592809?v=3","gravatar_id":"","url":"https://api.github.com/users/rjes","html_url":"https://github.com/rjes","followers_url":"https://api.github.com/users/rjes/followers","following_url":"https://api.github.com/users/rjes/following{/other_user}","gists_url":"https://api.github.com/users/rjes/gists{/gist_id}","starred_url":"https://api.github.com/users/rjes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rjes/subscriptions","organizations_url":"https://api.github.com/users/rjes/orgs","repos_url":"https://api.github.com/users/rjes/repos","events_url":"https://api.github.com/users/rjes/events{/privacy}","received_events_url":"https://api.github.com/users/rjes/received_events","type":"User","site_admin":false},"created_at":"2016-10-16T19:28:05Z","updated_at":"2016-10-16T19:28:05Z","body":"I think i found something now, the data parameter to curl need to urlencode the CSR:\r\n```\r\n-d \"subject[C]=SE&subject[ST]=Stockholm&subject[L]=Stockholm&subject[O]=Netnerdz&subject[OU]=CA-App&subject[CN]=test-cert&ca=ca-app.netnerdz.se&profile=server&validityPeriod=31536000&csr=-----BEGIN+CERTIFICATE+REQUEST-----%0D%0AMIICiTCCAXECAQAwRDELMAkGA1UEBhMCU0UxEjAQBgNVBAgMCVN0b2NraG9sbTEh%0D%0AMB8GA1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0B%0D%0AAQEFAAOCAQ8AMIIBCgKCAQEAypf%2B0Tlf5fPo5kgsBYdetr6mFLXwDGDlbkhWK9OR%0D%0ApZZSGMHrSH1aHQvJjCcYO1YD78Gte1W8z5erYVIaRSfoKfYvzVWW9%2BjihI7W1fsV%0D%0Axs8Uk48a6lnvULZVrSi3rcW%2F0eaXGBKrFYAaPtfnhM9snJwJ6fZWSj34jNENjFA%2B%0D%0ACYUslwW%2FAsqFhG8mD3DNEyFpF6mBK6%2FAzmQnyAw%2BRTQWTjI4riw1BoD0PNVDAnvT%0D%0AM%2FVijIglC202if027ZDDRJM1pFbUIx0XNEgLTojDuEF97Q5q2%2BarNHiTR%2FLW9%2BB9%0D%0AUMvCk%2F5znI2p2o7kBUCJtJFgNZnNK%2FigFUcXI4Lb7oXMeQIDAQABoAAwDQYJKoZI%0D%0AhvcNAQELBQADggEBAMcmfs%2FUQL%2BjvPxa7drFa%2BhdEBJu140OF%2B6sZUMSuCBhi1M2%0D%0Adek0nD0HIuEWmMRN8KiH9gNl7axuo1F1U1VK9AGm9H59EnSHInUMabgotnnPPf8n%0D%0A62jHhzH7sesgOCLPpRqVbrjNtbeu5HqK6jQZ7RXf%2Ft3zF688NABwidKTP4oJgjmV%0D%0AFWAC%2F60MeveQtcbsPhaC%2BLmgdVNqqXD9C22eBVwvjZg2VVWRSYaI596sAhOVWusJ%0D%0AJZI%2Fnc2ySp3bHkcvA37CP4yRPu3TCqNmfyJoGwZdRg0OZoYRD%2FTweE8BWZecxR93%0D%0AWkNFihGStMOX0c0LQ7fKpJT6%2Bzf%2F8GnIkaLr268%3D%0D%0A-----END+CERTIFICATE+REQUEST-----\"\r\n```\r\nThe endpoint doesn't accept:\r\nThe file as-is:\r\n```\r\n-d \"subject[C]=SE&subject[ST]=Stockholm&subject[L]=Stockholm&subject[O]=Netnerdz&subject[OU]=CA-App&subject[CN]=test-cert&ca=ca-app.netnerdz.se&profile=server&validityPeriod=31536000&csr=$(cat test-cert.csr)\"\r\n```\r\nor as a long string:\r\n```\r\n-d \"subject[C]=SE&subject[ST]=Stockholm&subject[L]=Stockholm&subject[O]=Netnerdz&subject[OU]=CA-App&subject[CN]=test-cert&ca=ca-app.netnerdz.se&profile=server&validityPeriod=31536000&csr=$(cat test-cert.csr | tr -d '\\n')\"\r\n```\r\nHere's a oneliner that works:\r\n```\r\n-d \"subject[C]=SE&subject[ST]=Stockholm&subject[L]=Stockholm&subject[O]=Netnerdz&subject[OU]=CA-App&subject[CN]=test-cert&ca=ca-app.netnerdz.se&profile=server&validityPeriod=31536000&csr=$(cat test-cert.csr| python2 -c \"import sys, urllib as ul; [sys.stdout.write(ul.quote_plus(l)) for l in sys.stdin]\")\" 172.20.202.20:9292/1/certificate/issue\r\n```\r\nI think it would be nice to have the r509-ca-http to handle the CSR as-is, to simplify integrations (and have a consequent handling of parameters).\r\nBut I don't mind if this issue is closed with \"wontfix\" since I know how to handle the request.\r\n"}}
{"actor":{"display_login":"rjes"}}