To detect X500 addresses, the regular expression is used: "/o=[^/]+/ou=[^/]+(?:/cn=[^/]+)?"
This regular expression accepts only one appearance of "cn=".
It is possible to have X500 addresses with multiple "cn=" parts, eg: "/o=Test/ou=Unit/cn=Recipients/cn=anassta".
In this case the above regular expression will not work.
Proposed solution is to change the regular expression to search for "one or more" "cn=" parts, by changing the final "?" into "+".
Eg: "/o=[^/]+/ou=[^/]+(?:/cn=[^/]+)+".
I tested with the proposed regular expression and it works for both cases:
- "/o=Test/ou=Unit/cn=Recipients/cn=anassta"
- "/o=Test/ou=Unit/cn=anassta"