| SerfSession.cxx (de38cc67) | SerfSession.cxx (10e20387) |
|---|---|
| 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 255 unchanged lines hidden (view full) --- 264 tmpInputBkt = serf_bucket_ssl_decrypt_create( tmpInputBkt, 265 0, 266 getSerfBktAlloc() ); 267 /** Set the callback that is called to authenticate the 268 certifcate (chain). 269 */ 270 serf_ssl_server_cert_chain_callback_set( 271 serf_bucket_ssl_decrypt_context_get(tmpInputBkt), | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 255 unchanged lines hidden (view full) --- 264 tmpInputBkt = serf_bucket_ssl_decrypt_create( tmpInputBkt, 265 0, 266 getSerfBktAlloc() ); 267 /** Set the callback that is called to authenticate the 268 certifcate (chain). 269 */ 270 serf_ssl_server_cert_chain_callback_set( 271 serf_bucket_ssl_decrypt_context_get(tmpInputBkt), |
| 272 NULL, |
|
| 272 Serf_CertificateChainValidation, 273 this); 274 serf_ssl_set_hostname( serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), 275 getHostinfo() ); 276 277 *outSerfOutputBucket = serf_bucket_ssl_encrypt_create( *outSerfOutputBucket, 278 serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), 279 getSerfBktAlloc() ); --- 82 unchanged lines hidden (view full) --- 362 } 363 return sPart; 364 } 365} // namespace 366 367 368apr_status_t SerfSession::verifySerfCertificateChain ( 369 int, | 273 Serf_CertificateChainValidation, 274 this); 275 serf_ssl_set_hostname( serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), 276 getHostinfo() ); 277 278 *outSerfOutputBucket = serf_bucket_ssl_encrypt_create( *outSerfOutputBucket, 279 serf_bucket_ssl_decrypt_context_get( tmpInputBkt ), 280 getSerfBktAlloc() ); --- 82 unchanged lines hidden (view full) --- 363 } 364 return sPart; 365 } 366} // namespace 367 368 369apr_status_t SerfSession::verifySerfCertificateChain ( 370 int, |
| 370 const char** pCertificateChainBase64Encoded, | 371 const serf_ssl_certificate_t * const * pCertificateChainBase64Encoded, |
| 371 int nCertificateChainLength) 372{ 373 // Check arguments. 374 if (pCertificateChainBase64Encoded == NULL || nCertificateChainLength<=0) 375 { 376 OSL_ASSERT(pCertificateChainBase64Encoded != NULL); 377 OSL_ASSERT(nCertificateChainLength>0); 378 return SERF_SSL_CERT_UNKNOWN_FAILURE; --- 30 unchanged lines hidden (view full) --- 409 } 410 } 411 catch ( uno::Exception const &) 412 { 413 return SERF_SSL_CERT_UNKNOWN_FAILURE; 414 } 415 416 // Decode the server certificate. | 372 int nCertificateChainLength) 373{ 374 // Check arguments. 375 if (pCertificateChainBase64Encoded == NULL || nCertificateChainLength<=0) 376 { 377 OSL_ASSERT(pCertificateChainBase64Encoded != NULL); 378 OSL_ASSERT(nCertificateChainLength>0); 379 return SERF_SSL_CERT_UNKNOWN_FAILURE; --- 30 unchanged lines hidden (view full) --- 410 } 411 } 412 catch ( uno::Exception const &) 413 { 414 return SERF_SSL_CERT_UNKNOWN_FAILURE; 415 } 416 417 // Decode the server certificate. |
| 418 const char* sBase64EncodedServerCertificate ( 419 serf_ssl_cert_export( 420 pCertificateChainBase64Encoded[0], 421 getAprPool())); |
|
| 417 uno::Reference< security::XCertificate > xServerCertificate( 418 xSecurityEnv->createCertificateFromAscii( | 422 uno::Reference< security::XCertificate > xServerCertificate( 423 xSecurityEnv->createCertificateFromAscii( |
| 419 rtl::OUString::createFromAscii(pCertificateChainBase64Encoded[0]))); | 424 rtl::OUString::createFromAscii(sBase64EncodedServerCertificate))); |
| 420 if ( ! xServerCertificate.is()) 421 return SERF_SSL_CERT_UNKNOWN_FAILURE; 422 423 // Get the subject from the server certificate. 424 ::rtl::OUString sServerCertificateSubject (xServerCertificate->getSubjectName()); 425 sal_Int32 nIndex = 0; 426 while (nIndex >= 0) 427 { --- 24 unchanged lines hidden (view full) --- 452 } 453 454 // The shortcut failed, so try to verify the whole chain. This is 455 // done outside the isDomainMatch() block because the result is 456 // used by the interaction handler. 457 std::vector< uno::Reference< security::XCertificate > > aChain; 458 for (int nIndex=1; nIndex<nCertificateChainLength; ++nIndex) 459 { | 425 if ( ! xServerCertificate.is()) 426 return SERF_SSL_CERT_UNKNOWN_FAILURE; 427 428 // Get the subject from the server certificate. 429 ::rtl::OUString sServerCertificateSubject (xServerCertificate->getSubjectName()); 430 sal_Int32 nIndex = 0; 431 while (nIndex >= 0) 432 { --- 24 unchanged lines hidden (view full) --- 457 } 458 459 // The shortcut failed, so try to verify the whole chain. This is 460 // done outside the isDomainMatch() block because the result is 461 // used by the interaction handler. 462 std::vector< uno::Reference< security::XCertificate > > aChain; 463 for (int nIndex=1; nIndex<nCertificateChainLength; ++nIndex) 464 { |
| 465 const char* sBase64EncodedCertificate ( 466 serf_ssl_cert_export( 467 pCertificateChainBase64Encoded[nIndex], 468 getAprPool())); |
|
| 460 uno::Reference< security::XCertificate > xCertificate( 461 xSecurityEnv->createCertificateFromAscii( | 469 uno::Reference< security::XCertificate > xCertificate( 470 xSecurityEnv->createCertificateFromAscii( |
| 462 rtl::OUString::createFromAscii(pCertificateChainBase64Encoded[nIndex]))); | 471 rtl::OUString::createFromAscii(sBase64EncodedCertificate))); |
| 463 if ( ! xCertificate.is()) 464 return SERF_SSL_CERT_UNKNOWN_FAILURE; 465 aChain.push_back(xCertificate); 466 } 467 const sal_Int64 nVerificationResult (xSecurityEnv->verifyCertificate( 468 xServerCertificate, 469 ::comphelper::containerToSequence(aChain))); 470 --- 1133 unchanged lines hidden --- | 472 if ( ! xCertificate.is()) 473 return SERF_SSL_CERT_UNKNOWN_FAILURE; 474 aChain.push_back(xCertificate); 475 } 476 const sal_Int64 nVerificationResult (xSecurityEnv->verifyCertificate( 477 xServerCertificate, 478 ::comphelper::containerToSequence(aChain))); 479 --- 1133 unchanged lines hidden --- |