summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorGabor Kelemen <kelemen.gabor2@nisz.hu>2020-04-22 10:25:57 +0200
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-04-29 07:05:36 +0200
commitbedba76adb9b1421a7d939cfef44b8194e987888 (patch)
treee7a6925910d17e62c9ed7814b59dd6f98d86e7e9 /comphelper/source
parent14fef320301f71f68547af1c0527677cc0ef6f88 (diff)
tdf#131733 Show only CN part of X.509 subject info
The problem was that the whole Subject info was returned from X.509 certs if they did not start with one of "CN", "OU", "O", "E" Instead of extending this list with random keys, pass the type of cert and only return the whole Subject info if it's an OpenGPG one, and process the info unconditionally if it's X.509 like before the OpenGPG integration Change-Id: I1aa5d7285e48b0f4a769a073cdfb7732e482792c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92675 Tested-by: Jenkins Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
Diffstat (limited to 'comphelper/source')
-rw-r--r--comphelper/source/misc/xmlsechelper.cxx19
1 files changed, 5 insertions, 14 deletions
diff --git a/comphelper/source/misc/xmlsechelper.cxx b/comphelper/source/misc/xmlsechelper.cxx
index c8257c124755..c01743b36615 100644
--- a/comphelper/source/misc/xmlsechelper.cxx
+++ b/comphelper/source/misc/xmlsechelper.cxx
@@ -258,25 +258,16 @@ vector< pair< OUString, OUString> > parseDN(const OUString& rRawString)
#endif
- OUString GetContentPart( const OUString& _rRawString )
+ OUString GetContentPart( const OUString& _rRawString, const css::security::CertificateKind &rKind )
{
char const * aIDs[] = { "CN", "OU", "O", "E", nullptr };
- bool shouldBeParsed = false;
- int i = 0;
- while ( aIDs[i] )
- {
- if (_rRawString.startsWith(OUString::createFromAscii(aIDs[i++])))
- {
- shouldBeParsed = true;
- break;
- }
- }
- if (!shouldBeParsed)
+ // tdf#131733 Don't process OpenPGP certs, only X509
+ if (rKind == css::security::CertificateKind_OPENPGP )
return _rRawString;
OUString retVal;
- i = 0;
+ int i = 0;
vector< pair< OUString, OUString > > vecAttrValueOfDN = parseDN(_rRawString);
while ( aIDs[i] )
{
@@ -288,7 +279,7 @@ vector< pair< OUString, OUString> > parseDN(const OUString& rRawString)
if (!retVal.isEmpty())
break;
}
- return retVal;
+ return retVal.isEmpty() ? _rRawString : retVal;
}
OUString GetHexString( const css::uno::Sequence< sal_Int8 >& _rSeq, const char* _pSep, sal_uInt16 _nLineBreak )