Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: chrome/third_party/mozilla_security_manager/nsNSSCertHelper.cpp

Issue 10309002: Reimplements net::AddressList without struct addrinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: get_canonical_name -> canonical_name. iterator to indexing Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* ***** BEGIN LICENSE BLOCK ***** 1 /* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3 * 3 *
4 * The contents of this file are subject to the Mozilla Public License Version 4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with 5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at 6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/ 7 * http://www.mozilla.org/MPL/
8 * 8 *
9 * Software distributed under the License is distributed on an "AS IS" basis, 9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include <prprf.h> 44 #include <prprf.h>
45 #include <unicode/uidna.h> 45 #include <unicode/uidna.h>
46 46
47 #include "base/i18n/number_formatting.h" 47 #include "base/i18n/number_formatting.h"
48 #include "base/string_number_conversions.h" 48 #include "base/string_number_conversions.h"
49 #include "base/stringprintf.h" 49 #include "base/stringprintf.h"
50 #include "base/utf_string_conversions.h" 50 #include "base/utf_string_conversions.h"
51 #include "chrome/common/net/x509_certificate_model.h" 51 #include "chrome/common/net/x509_certificate_model.h"
52 #include "crypto/scoped_nss_types.h" 52 #include "crypto/scoped_nss_types.h"
53 #include "grit/generated_resources.h" 53 #include "grit/generated_resources.h"
54 #include "net/base/ip_endpoint.h"
54 #include "net/base/net_util.h" 55 #include "net/base/net_util.h"
55 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h" 56 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h"
56 #include "ui/base/l10n/l10n_util.h" 57 #include "ui/base/l10n/l10n_util.h"
57 58
58 namespace { 59 namespace {
59 60
60 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data, 61 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data,
61 unsigned int len) { 62 unsigned int len) {
62 if (len % 2 != 0) 63 if (len % 2 != 0)
63 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); 64 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR);
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_EDI_PARTY_NAME); 522 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_EDI_PARTY_NAME);
522 value = ProcessRawBytes(&current->name.other); 523 value = ProcessRawBytes(&current->name.other);
523 break; 524 break;
524 case certURI: 525 case certURI:
525 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_URI); 526 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_URI);
526 value = std::string(reinterpret_cast<char*>(current->name.other.data), 527 value = std::string(reinterpret_cast<char*>(current->name.other.data),
527 current->name.other.len); 528 current->name.other.len);
528 break; 529 break;
529 case certIPAddress: { 530 case certIPAddress: {
530 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_IP_ADDRESS); 531 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_IP_ADDRESS);
531 struct addrinfo addr = {0}; 532 net::IPAddressNumber ip(
532 if (current->name.other.len == 4) { 533 current->name.other.data,
533 struct sockaddr_in addr4 = {0}; 534 current->name.other.data + current->name.other.len);
534 addr.ai_addr = reinterpret_cast<sockaddr*>(&addr4); 535 value = net::IPEndPoint(ip, 0).ToStringWithoutPort();
535 addr.ai_addrlen = sizeof(addr4);
536 addr.ai_family = AF_INET;
537 addr4.sin_family = addr.ai_family;
538 memcpy(&addr4.sin_addr, current->name.other.data,
539 current->name.other.len);
540 value = net::NetAddressToString(&addr);
541 } else if (current->name.other.len == 16) {
542 struct sockaddr_in6 addr6 = {0};
543 addr.ai_addr = reinterpret_cast<sockaddr*>(&addr6);
544 addr.ai_addrlen = sizeof(addr6);
545 addr.ai_family = AF_INET6;
546 addr6.sin6_family = addr.ai_family;
547 memcpy(&addr6.sin6_addr, current->name.other.data,
548 current->name.other.len);
549 value = net::NetAddressToString(&addr);
550 }
551 if (value.empty()) { 536 if (value.empty()) {
552 // Invalid IP address. 537 // Invalid IP address.
553 value = ProcessRawBytes(&current->name.other); 538 value = ProcessRawBytes(&current->name.other);
554 } 539 }
555 break; 540 break;
556 } 541 }
557 case certRegisterID: 542 case certRegisterID:
558 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_REGISTERED_ID); 543 key = l10n_util::GetStringUTF8(IDS_CERT_GENERAL_NAME_REGISTERED_ID);
559 value = DumpOidString(&current->name.other); 544 value = DumpOidString(&current->name.other);
560 break; 545 break;
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 if (cert->nickname && trust.HasAnyUser()) 1042 if (cert->nickname && trust.HasAnyUser())
1058 return net::USER_CERT; 1043 return net::USER_CERT;
1059 if (trust.HasAnyCA() || CERT_IsCACert(cert, NULL)) 1044 if (trust.HasAnyCA() || CERT_IsCACert(cert, NULL))
1060 return net::CA_CERT; 1045 return net::CA_CERT;
1061 if (trust.HasPeer(PR_TRUE, PR_FALSE, PR_FALSE)) 1046 if (trust.HasPeer(PR_TRUE, PR_FALSE, PR_FALSE))
1062 return net::SERVER_CERT; 1047 return net::SERVER_CERT;
1063 return net::UNKNOWN_CERT; 1048 return net::UNKNOWN_CERT;
1064 } 1049 }
1065 1050
1066 } // namespace mozilla_security_manager 1051 } // namespace mozilla_security_manager
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/net_internals/net_internals_ui.cc ('k') | content/browser/renderer_host/p2p/socket_dispatcher_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698