Kaydet (Commit) 59bcc90c authored tarafından Miklos Vajna's avatar Miklos Vajna

xmlsecurity: use comphelper::containerToSequence()

Allows not iterating the certificate chain twice.

Change-Id: I3993f8af24b28bef505d0e8c24bce8065580c2cf
Reviewed-on: https://gerrit.libreoffice.org/59780
Tested-by: Jenkins
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 07b71a93
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include <osl/thread.h> #include <osl/thread.h>
#include <comphelper/sequence.hxx>
#include "secerror.hxx" #include "secerror.hxx"
...@@ -438,15 +439,10 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi ...@@ -438,15 +439,10 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi
} }
if( certChain != nullptr ) { if( certChain != nullptr ) {
X509Certificate_NssImpl* pCert ; std::vector<uno::Reference<security::XCertificate>> aCertChain;
CERTCertListNode* node ;
int len ;
for( len = 0, node = CERT_LIST_HEAD( certChain ); !CERT_LIST_END( node, certChain ); node = CERT_LIST_NEXT( node ), len ++ ) ; for (CERTCertListNode* node = CERT_LIST_HEAD(certChain); !CERT_LIST_END(node, certChain); node = CERT_LIST_NEXT(node)) {
Sequence< Reference< XCertificate > > xCertChain( len ) ; X509Certificate_NssImpl* pCert = new X509Certificate_NssImpl();
for( len = 0, node = CERT_LIST_HEAD( certChain ); !CERT_LIST_END( node, certChain ); node = CERT_LIST_NEXT( node ), len ++ ) {
pCert = new X509Certificate_NssImpl() ;
if( pCert == nullptr ) { if( pCert == nullptr ) {
CERT_DestroyCertList( certChain ) ; CERT_DestroyCertList( certChain ) ;
throw RuntimeException() ; throw RuntimeException() ;
...@@ -454,12 +450,12 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi ...@@ -454,12 +450,12 @@ Sequence< Reference < XCertificate > > SecurityEnvironment_NssImpl::buildCertifi
pCert->setCert( node->cert ) ; pCert->setCert( node->cert ) ;
xCertChain[len] = pCert ; aCertChain.push_back(pCert);
} }
CERT_DestroyCertList( certChain ) ; CERT_DestroyCertList( certChain ) ;
return xCertChain ; return comphelper::containerToSequence(aCertChain);
} }
return Sequence< Reference < XCertificate > >(); return Sequence< Reference < XCertificate > >();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment