diff options
-rw-r--r-- | uui/source/iahndl-ssl.cxx | 23 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx | 46 | ||||
-rw-r--r-- | xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx | 3 |
3 files changed, 39 insertions, 33 deletions
diff --git a/uui/source/iahndl-ssl.cxx b/uui/source/iahndl-ssl.cxx index 20688f7a3c9f..aa31496e1bdb 100644 --- a/uui/source/iahndl-ssl.cxx +++ b/uui/source/iahndl-ssl.cxx @@ -28,6 +28,7 @@ #include <com/sun/star/ucb/CertificateValidationRequest.hpp> #include <com/sun/star/uno/Reference.hxx> +#include <comphelper/sequence.hxx> #include <osl/mutex.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <svl/zforlist.hxx> @@ -272,27 +273,33 @@ handleCertificateValidationRequest_( } uno::Sequence< uno::Reference< security::XCertificateExtension > > extensions = rRequest.Certificate->getExtensions(); - uno::Sequence< security::CertAltNameEntry > altNames; - for (sal_Int32 i = 0 ; i < extensions.getLength(); i++){ + uno::Reference< security::XSanExtension > sanExtension; + for (sal_Int32 i = 0 ; i < extensions.getLength(); ++i) + { uno::Reference< security::XCertificateExtension >element = extensions[i]; - OString aId ( reinterpret_cast<const char *>(element->getExtensionId().getConstArray()), element->getExtensionId().getLength()); if (aId.equals(OID_SUBJECT_ALTERNATIVE_NAME)) { - uno::Reference< security::XSanExtension > sanExtension ( element, uno::UNO_QUERY ); - altNames = sanExtension->getAlternativeNames(); + sanExtension = uno::Reference<security::XSanExtension>(element, uno::UNO_QUERY); break; } } + std::vector<security::CertAltNameEntry> altNames; + if (sanExtension.is()) + { + altNames = comphelper::sequenceToContainer<std::vector<security::CertAltNameEntry>>(sanExtension->getAlternativeNames()); + } + OUString certHostName = getContentPart( rRequest.Certificate->getSubjectName() ); - uno::Sequence< OUString > certHostNames(altNames.getLength() + 1); + uno::Sequence< OUString > certHostNames(altNames.size() + 1); certHostNames[0] = certHostName; - for(int n = 0; n < altNames.getLength(); ++n) + for (size_t n = 0; n < altNames.size(); ++n) { - if (altNames[n].Type == security::ExtAltNameType_DNS_NAME){ + if (altNames[n].Type == security::ExtAltNameType_DNS_NAME) + { altNames[n].Value >>= certHostNames[n+1]; } } diff --git a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx index 5e614631e944..fc0e05e3ff1e 100644 --- a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx +++ b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.cxx @@ -58,9 +58,9 @@ namespace { } //Methods from XSanExtension -css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl::getAlternativeNames() throw( css::uno::RuntimeException, std::exception ){ - - if (!m_Entries.hasElements()) +css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl::getAlternativeNames() throw( css::uno::RuntimeException, std::exception ) +{ + if (m_Entries.empty()) { SECItem item; @@ -73,18 +73,18 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); if (!arena) - return m_Entries; + return css::uno::Sequence<css::security::CertAltNameEntry>(); nameList = CERT_DecodeAltNameExtension(arena, &item); CERTGeneralName* current = nameList; int size = GetNamesLength(nameList); - std::vector<CertAltNameEntry> arrCertAltNameEntry(size); - for(int i = 0; i < size ; i++){ + m_Entries.resize(size); + for(int i = 0; i < size; ++i){ switch (current->type) { case certOtherName: { - arrCertAltNameEntry[i].Type = ExtAltNameType_OTHER_NAME; + m_Entries[i].Type = ExtAltNameType_OTHER_NAME; css::beans::PropertyValue otherNameProp; otherNameProp.Name = OUString::createFromAscii(CERT_GetOidString(¤t->name.OthName.oid)); @@ -94,64 +94,62 @@ css::uno::Sequence< css::security::CertAltNameEntry > SAL_CALL SanExtensionImpl: otherNameProp.Value <<= otherName; - arrCertAltNameEntry[i].Value <<= otherNameProp; + m_Entries[i].Value <<= otherNameProp; break; } case certRFC822Name: - arrCertAltNameEntry[i].Type = ExtAltNameType_RFC822_NAME; - arrCertAltNameEntry[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); + m_Entries[i].Type = ExtAltNameType_RFC822_NAME; + m_Entries[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); break; case certDNSName: - arrCertAltNameEntry[i].Type = ExtAltNameType_DNS_NAME; - arrCertAltNameEntry[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); + m_Entries[i].Type = ExtAltNameType_DNS_NAME; + m_Entries[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); break; case certX400Address: { // unsupported - arrCertAltNameEntry[i].Type = ExtAltNameType_X400_ADDRESS; + m_Entries[i].Type = ExtAltNameType_X400_ADDRESS; break; } case certDirectoryName: { // unsupported - arrCertAltNameEntry[i].Type = ExtAltNameType_DIRECTORY_NAME; + m_Entries[i].Type = ExtAltNameType_DIRECTORY_NAME; break; } case certEDIPartyName: { // unsupported - arrCertAltNameEntry[i].Type = ExtAltNameType_EDI_PARTY_NAME; + m_Entries[i].Type = ExtAltNameType_EDI_PARTY_NAME; break; } case certURI: - arrCertAltNameEntry[i].Type = ExtAltNameType_URL; - arrCertAltNameEntry[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); + m_Entries[i].Type = ExtAltNameType_URL; + m_Entries[i].Value <<= OUString(reinterpret_cast<char*>(current->name.other.data), current->name.other.len, RTL_TEXTENCODING_ASCII_US); break; case certIPAddress: { - arrCertAltNameEntry[i].Type = ExtAltNameType_IP_ADDRESS; + m_Entries[i].Type = ExtAltNameType_IP_ADDRESS; Sequence< sal_Int8 > ipAddress( current->name.other.len ) ; for( unsigned int r = 0; r < current->name.other.len ; r ++ ) ipAddress[r] = *( current->name.other.data + r ) ; - arrCertAltNameEntry[i].Value <<= ipAddress; + m_Entries[i].Value <<= ipAddress; break; } case certRegisterID: - arrCertAltNameEntry[i].Type = ExtAltNameType_REGISTERED_ID; + m_Entries[i].Type = ExtAltNameType_REGISTERED_ID; OString nssOid = OString(CERT_GetOidString(¤t->name.other)); OString unoOid = removeOIDFromString(nssOid); - arrCertAltNameEntry[i].Value <<= OStringToOUString( unoOid, RTL_TEXTENCODING_ASCII_US ); + m_Entries[i].Value <<= OStringToOUString( unoOid, RTL_TEXTENCODING_ASCII_US ); break; } current = CERT_GetNextGeneralName(current); } - m_Entries = ::comphelper::containerToSequence<css::security::CertAltNameEntry>(arrCertAltNameEntry); - PORT_FreeArena(arena, PR_FALSE); } - return m_Entries; + return comphelper::containerToSequence<css::security::CertAltNameEntry>(m_Entries); } OString SanExtensionImpl::removeOIDFromString( const OString &oidString) diff --git a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx index ca7401884d7f..df81eee47408 100644 --- a/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx +++ b/xmlsecurity/source/xmlsec/nss/sanextension_nssimpl.hxx @@ -30,13 +30,14 @@ #include <com/sun/star/security/XSanExtension.hpp> #include <com/sun/star/security/CertAltNameEntry.hpp> #include "certificateextension_certextn.hxx" +#include <vector> class SanExtensionImpl : public ::cppu::WeakImplHelper< css::security::XSanExtension > { private: CertificateExtension_CertExtn m_Extn; - css::uno::Sequence< css::security::CertAltNameEntry > m_Entries; + std::vector<css::security::CertAltNameEntry> m_Entries; static OString removeOIDFromString( const OString &oid); |