indigo-iam / iam

INDIGO Identity and Access Management Service
https://indigo-iam.github.io/
Other
99 stars 43 forks source link

Unable to link certificate with special characters in the subject #533

Open vokac opened 1 year ago

vokac commented 1 year ago

I'm not able to link certificate with this subject using IAM web interface that shows following dialog Link user certificate dialog but nothing gets added by pushing "Link" button. It is also interesting that login page displays certificate subject differently Login dialog with user certificate subject.

I'm not even able to add this certificate subject directly with API using

> PATCH /scim/Users/266d17cd-3f59-6093-b3ab-cc65afa33850 HTTP/1.1
> Host: atlas-auth.web.cern.ch
> Accept-Encoding: identity
> Content-type: application/scim+json
> Authorization: Bearer secret
> Content-Length: 582
>
> {"schemas": ["urn:ietf:params:scim:api:messages:2.0:PatchOp"], "operations": [{"op": "add", "path": "certificates", "value": {"urn:indigo-dc:scim:schemas:IndigoUser": {"certificates": [{"label": "cert-1", "subjectDn": "emailAddress=petr.vokac@fjfi.cvut.cz,CN=Petr Vok\\\\C3\\\\A1\\\\C4\\\\8D,C=CZ,L=Praha 6 - Dejvice,ST=Praha\\\\, Hlavn\\\\C3\\\\AD m\\\\C4\\\\9Bsto,street=Jugosl\\\\C3\\\\A1vsk\\\\C3\\\\BDch partyz\\\\C3\\\\A1n\\\\C5\\\\AF 1580/3,O=\\\\C4\\\\8Cesk\\\\C3\\\\A9 vysok\\\\C3\\\\A9 u\\\\C4\\\\8Den\\\\C3\\\\AD technick\\\\C3\\\\A9 v Praze,postalCode=160 00", "issuerDn": "CN=GEANT Personal CA 4,O=GEANT Vereniging,C=NL"}]}}}]}

< HTTP/1.1 400 Bad Request
< Server: nginx/1.17.9
< Date: Thu, 24 Nov 2022 23:44:27 GMT
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< Access-Control-Allow-Origin: *
< X-Content-Type-Options: nosniff
< X-XSS-Protection: 1; mode=block
< Cache-Control: no-cache, no-store, max-age=0, must-revalidate
< Pragma: no-cache
< Expires: 0
< Strict-Transport-Security: max-age=31536000 ; includeSubDomains
< X-Frame-Options: DENY
< X-Application-Context: INDIGO IAM:mysql,flyway-repair,prod,oidc,cern,registration,wlcg-scopes:8080
giacomini commented 1 year ago

Are non-ascii characters allowed? see https://wiki.geant.org/display/TCSNT/TCS+2020+FAQ#TCS2020FAQ-Q:HowdoIdealwithnon-ASCIIcharactersforIGTFcertificates?

giacomini commented 1 year ago

I've found this https://ggus.eu/index.php?mode=ticket_info&ticket_id=152981. In particular, update#5 cites https://www.ogf.org/documents/GFD.125.pdf as forbidding non-ASCII characters in IGTF certificates. I'm checking if that document is still relevant.

msalle commented 1 year ago

Hi all, the problem is that it's GEANT Personal CA 4 certificate, not the IGTF-MICS version (you should be able to choose that when getting a certificate from the GEANT TCS). For the personal UTF-8 is fine, for IGTF it's not. The best reference is https://www.ogf.org/documents/GFD.225.pdf as referred to from https://www.eugridpma.org/guidelines/pkitech/ See in particular §4.3 in GFD.225

vokac commented 1 year ago

"solved" by secondary CERN account which can be used to issue different certificate for my second IAM account.

Our national CA operator CESNET no longer issue TCS grid certificates and it is too complicated / time consuming to get personal certificate from their own CESNET CA4 personal authority.

vokac commented 1 year ago

Still, it would be nice if IAM prints error while trying to link "bad" certificate and not just blank page. Actually, page is not empty and it contains, e.g.

Internal Exception: com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'subject_dn' at row 1
Error Code: 1406
Call: INSERT INTO iam_x509_cert (CERTIFICATE, creation_time, issuer_dn, LABEL, last_update_time, is_primary, subject_dn, account_id, proxy_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
    bind =&gt; [9 parameters bound]
Query: InsertObjectQuery(IamX509Certificate [label=cert-1, subjectDn=emailAddress=petr.vokac@fjfi.cvut.cz,CN=Petr Vok\C3\A1\C4\8D,C=CZ,L=Praha 6 - Dejvice,ST=Praha\, Hlavn\C3\AD m\C4\9Bsto,street=Jugosl\C3\A1vsk\C3\BDch partyz\C3\A1n\C5\AF 1580/3,O=\C4\8Cesk\C3\A9 vysok\C3\A9 u\C4\8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v41Vchhl9ExhzksRa5jttuOD9/vnV9E6KOiiYP4pBH
DxPDm1+oxOHVJVF6J5/scgLsE8yYrl0amAaG3shbk8YBItyeGl9MEOOsXvEYo6aM
Cmdf1mQW4m0LZKuf5LGLj4op5jihDr9+dJoQt67AOv/z1r7lR04FlMdu6VKItTty
PiIFrsyoNgMUP+J4DMphB/gCIahHYsA47P/2GxtG1F8mgdlVc3yWZBTOqg==
-----END CERTIFICATE-----, primary=true, creationTime=Mon Nov 28 11:41:57 CET 2022, lastUpdateTime=Mon Nov 28 11:41:57 CET 2022])"
msalle commented 1 year ago

I agree a clear error message would definitely be good. Also, if it is IGTF only, it should not have the GEANT Personal CA 4 configured as acceptable CA, but only the IGTF bundles.

giacomini commented 1 year ago

From the output of openssl s_client, I see only IGTF CAs. I agree that the messages should be more informative.

msalle commented 1 year ago

Ah, right. The client is probably sending both the EEC and the "GEANT Personal CA 4" certificates. The latter (see https://crt.sh/?caid=160144) is issued by the same CA as the "GEANT eScience Personal CA 4" (see https://crt.sh/?caid=160134), hence the chain is still accepted since that common parent is in the IGTF distribution (ca_USERTrustRSACertificationAuthority-1.117-1). There isn't much one can do about that.