<div dir="ltr">Yes, good catch for the cookie header.<div>Thanks for the feedback to the list.<div>M.</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Feb 8, 2021 at 1:17 PM Perig Bouenou <<a href="mailto:pseite35@gmail.com">pseite35@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Actually, I forgot to include the session coolie in the requests... Here is a script that works:</div><div><br></div><div>curl -I -c /tmp/cookie --cert-type P12 --cert ca_admin_cert.p12:$PWD  <a href="https://dogtag.org:8443/ca/rest/account/login" target="_blank">https://dogtag.org:8443/ca/rest/account/login</a></div><br>curl -s -b /tmp/cookie -H "Accept: application/xml" --cert-type P12 --cert ca_admin_cert.p12:$PWD <a href="https://dogtag.org:8443/ca/rest/agent/certrequests/$ID" target="_blank">https://dogtag.org:8443/ca/rest/agent/certrequests/$ID</a> | xmllint --format - > review.xml<br><br><div>curl -X POST -s -b /tmp/cookie  --cert-type P12 --cert ca_admin_cert.p12:$PWD <a href="https://dogtag.org:8443/ca/rest/agent/certrequests/$ID/approve" target="_blank">https://dogtag.org:8443/ca/rest/agent/certrequests/$ID/approve</a> --header "Content-Type:application/xml" -H "Accept: application/json" -d @review.xml | jq</div><div><br></div><div>Hopefully it can be useful for someone else...<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 8 févr. 2021 à 18:40, Perig Bouenou <<a href="mailto:pseite35@gmail.com" target="_blank">pseite35@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>according to the debug logs in /var/log/pki/pki-tomcat/ca/, it seems that  login permission for certServer.ca.account are not set and the session is not created. <br></div><div><br></div>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: CertUserDBAuthentication: UID caadmin authenticated.<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: User ID: caadmin<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: UGSubsystem: retrieving user uid=caadmin,ou=People,dc=ca,dc=pki,dc=nono,dc=org<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: User DN: uid=caadmin,ou=people,dc=ca,dc=pki,dc=nono,dc=org<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: Roles:<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Certificate Manager Agents<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Security Domain Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise CA Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise KRA Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise OCSP Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise TKS Administrators<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise RA Administrators<br><div>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: PKIRealm: - Enterprise TPS Administrators</div><div><br></div><div>Here, Granting login permission for certServer.ca.account  and Creating session are missing...<br></div><div><br></div><div><br></div>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: UGSubsystem: retrieving user uid=caadmin,ou=People,dc=ca,dc=pki,dc=nono,dc=org<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: AAclAuthz: Granting execute permission for certServer.ca.certrequests<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: CertRequestService: Validating certificate request 12<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: DBSSession: reading cn=12,ou=ca,ou=requests,dc=ca,dc=pki,dc=nono,dc=org<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: UGSubsystem: retrieving user uid=caadmin,ou=People,dc=ca,dc=pki,dc=nono,dc=org<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: AAclAuthz: Granting approve permission for certServer.ca.request.profile<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] INFO: CAProcessor: Nonce: 2691022150130176365<br>2021-02-08 16:22:35 [https-jsse-nio-8443-exec-25] WARNING: CAProcessor: Nonce for cert-request 12 does not exist</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 8 févr. 2021 à 16:57, Perig Bouenou <<a href="mailto:pseite35@gmail.com" target="_blank">pseite35@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">BTW, it is similar issue than raised in <a href="https://www.redhat.com/archives/pki-users/2019-May/msg00002.html" target="_blank">https://www.redhat.com/archives/pki-users/2019-May/msg00002.html</a> ...<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le lun. 8 févr. 2021 à 16:51, Perig Bouenou <<a href="mailto:pseite35@gmail.com" target="_blank">pseite35@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<br><br>Thanks for the hint. Now, I make with curl the same queries than "a pki -U <a href="http://dogtag.org:8080" target="_blank">http://dogtag.org:8080</a> -C nss_pwd -n caadmin ca-cert-request-review 8 --action approve"  (I'm using unsecure port to be able to capture unencrypted queries to the API):<br><br>I start with a login and a review to get a nonce: <br><br>curl -s --cert-type P12 --cert ca_admin_cert.p12:<pkc12pwd> <a href="https://dogtag.org:8443/ca/rest/account/login" target="_blank">https://dogtag.org:8443/ca/rest/account/login</a><br>curl -s -H "Accept: application/xml" --cert-type P12 --cert ca_admin_cert.p12:<pkc12pwd> <a href="https://dogtag.org:8443/ca/rest/agent/certrequests/08" target="_blank">https://dogtag.org:8443/ca/rest/agent/certrequests/08</a> | xmllint --format - > 08.xml<br><br>The nonce is well generated:<br><br>$ grep nonce 08.xml <br>  <nonce>-8605088983470492766</nonce><br><br>Then, I do a curl/POST to /ca/rest/agent/certrequests/8/approve, but the request returns the error "Nonce for cert-request 8 does not exist"<br><br>curl -X POST  --cert-type P12 --cert ca_admin_cert.p12:<pkc12pwd> <a href="https://dogtag.org:8443/ca/rest/agent/certrequests/8/approve" target="_blank">https://dogtag.org:8443/ca/rest/agent/certrequests/8/approve</a> --header "Content-Type:application/xml" -H "Accept: application/json"<br>{<br>  "Attributes": {<br>    "Attribute": []<br>  },<br>  "ClassName": "com.netscape.certsrv.base.BadRequestException",<br>  "Code": 400,<br>  "Message": "Nonce for cert-request 8 does not exist"<br>}<br><br>Something is missing... any ideas?<br><br>BR</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 4 févr. 2021 à 23:38, Marc Sauton <<a href="mailto:msauton@redhat.com" target="_blank">msauton@redhat.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">or use the pki command like tool with the option ca-cert-request-review :<div><a href="https://github.com/dogtagpki/pki/wiki/Handling-Certificate-Request" target="_blank">https://github.com/dogtagpki/pki/wiki/Handling-Certificate-Request</a><br></div><div>for example:</div><div>pki -U <a href="https://ca1.example.test:8443/ca" target="_blank">https://ca1.example.test:8443/ca</a> -d ~/.dogtag/subca1 -C ~/.dogtag/subca1/pwdfile.txt -n caadmin ca-cert-request-review 1011 --action approve</div><div><br></div><div>and after successful authentication, the URI is in the form of /ca/rest/agent/certrequests/xx/approve</div><div>where xx is the request id</div><div>it is a HTTPS POST operation</div><div><br></div><div>Thanks,</div><div>M.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 4, 2021 at 1:43 AM Perig Bouenou <<a href="mailto:pseite35@gmail.com" target="_blank">pseite35@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello<br><br><br>I'm trying to approve certificate requests by using curl as in <a href="https://github.com/dogtagpki/pki/wiki/PKI-CA-Approve-Certificate-Request-REST-API" target="_blank">https://github.com/dogtagpki/pki/wiki/PKI-CA-Approve-Certificate-Request-REST-API</a> <br><br><div>I manage to submit certificate requests by posting an xml request template, I can retrieve the list of requests, the curl command for a review works fine, but I'm stuck with approval by using curl (I can approve CSR with pki tool but I still don't know do the same with curl). <br></div><div><br></div><div>BTW, here is my command for reviewing request:</div><br>curl -ks -X GET  --cert-type P12 --cert ca_admin_cert.p12:<password> <a href="https://dogtag.server:8443/ca/rest/agent/certrequests/08" target="_blank">https://dogtag.server:8443/ca/rest/agent/certrequests/08</a> --header "Content-Type:application/xml" |  xmllint --format -<br><br><br>Can someone tell me what's the correct curl command to approve cr? or is there any example of request approval (with curl) somewhere? or even something more detailed than <a href="https://github.com/dogtagpki/pki/wiki/PKI-CA-Approve-Certificate-Request-REST-API" target="_blank">https://github.com/dogtagpki/pki/wiki/PKI-CA-Approve-Certificate-Request-REST-API</a>?<br><br>PS: I had a look at the JAVA API (<a href="https://github.com/dogtagpki/pki/wiki/PKI-CA-Java-API#approving-a-certificate-request" target="_blank">https://github.com/dogtagpki/pki/wiki/PKI-CA-Java-API#approving-a-certificate-request</a>) but it didn't help me so much.<br><br>Regards,<br>Pier</div>
_______________________________________________<br>
Pki-users mailing list<br>
<a href="mailto:Pki-users@redhat.com" target="_blank">Pki-users@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/pki-users" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/pki-users</a></blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>