{"action":"created","comment":{"url":"https://api.github.com/repos/vmware/vic/pulls/comments/83737144","pull_request_review_id":4561410,"id":83737144,"diff_hunk":"@@ -211,41 +211,87 @@ func (d *Dispatcher) CollectDiagnosticLogs() {\n \t}\n }\n \n-func addrToUse(ip string, conf *config.VirtualContainerHostConfigSpec) (string, error) {\n+// given a set of IP addresses this will determine what address, if any, can be used to\n+// connect to the host certificate\n+// if none can be found, will return empty string and an err\n+func addrToUse(candidateIPs []net.IP, cert *x509.Certificate, cas []byte) (string, error) {\n+\tif cert == nil {\n+\t\treturn \"\", errors.New(\"unable to determine suitable address with nil certificate\")\n+\t}\n+\n \tlog.Debug(\"Loading CAs for client auth\")\n \tpool := x509.NewCertPool()\n-\tpool.AppendCertsFromPEM(conf.CertificateAuthorities)\n+\tpool.AppendCertsFromPEM(cas)\n \n \t// update target to use FQDN\n-\tnames, err := net.LookupAddr(ip)\n-\tif err != nil {\n-\t\tlog.Debugf(\"Unable to perform reverse lookup of IP address: %s\", err)\n+\tfor _, ip := range candidateIPs {\n+\t\tnames, err := net.LookupAddr(ip.String())\n+\t\tif err != nil {\n+\t\t\tlog.Debugf(\"Unable to perform reverse lookup of IP address: %s\", err)\n+\t\t}\n+\n+\t\t// check all the returned names, and lastly the raw IP\n+\t\tfor _, n := range append(names, ip.String()) {\n+\t\t\topts := x509.VerifyOptions{\n+\t\t\t\tRoots:   pool,\n+\t\t\t\tDNSName: n,\n+\t\t\t}\n+\n+\t\t\t_, err := cert.Verify(opts)\n+\t\t\tif err == nil {\n+\t\t\t\t// this identifier will work\n+\t\t\t\tlog.Debugf(\"Matched %s for use against host certificate\", n)\n+\t\t\t\t// trim '.' fqdn suffix if fqdn\n+\t\t\t\treturn strings.TrimSuffix(n, \".\"), nil\n+\t\t\t}\n+\n+\t\t\tlog.Debugf(\"Checked %s, no match for host cert\", n)\n+\t\t}\n \t}\n \n-\tcert, err := conf.HostCertificate.X509Certificate()\n-\tif err != nil {\n-\t\tlog.Debugf(\"Unable to extract host certificate: %s\", err)\n-\t\treturn ip, err\n+\t// no viable address\n+\treturn \"\", errors.New(\"unable to determine viable address\")\n+}\n+\n+/// viableHostAddresses attempts to determine which possibles addresses in the certificate\n+// are viable from the current location.\n+// This will return all IP addresses - it attempts to validate DNS names via resolution.\n+// This does NOT check connectivity\n+func viableHostAddress(candidateIPs []net.IP, cert *x509.Certificate, cas []byte) (string, error) {\n+\tif cert == nil {\n+\t\treturn \"\", fmt.Errorf(\"unable to determine suitable address with nil certificate\")\n \t}\n \n-\t// check all the returned names, and lastly the raw IP\n-\tfor _, n := range append(names, ip) {\n-\t\topts := x509.VerifyOptions{\n-\t\t\tRoots:   pool,\n-\t\t\tDNSName: n,\n-\t\t}\n+\tlog.Debug(\"Loading CAs for client auth\")\n+\tpool := x509.NewCertPool()\n+\tpool.AppendCertsFromPEM(cas)\n+\n+\tdnsnames := cert.DNSNames\n+\n+\t// assemble the common name and alt names\n+\tip := net.ParseIP(cert.Subject.CommonName)\n+\tif ip != nil {\n+\t\tcandidateIPs = append(candidateIPs, ip)\n+\t} else {\n+\t\t// assume it's dns\n+\t\tdnsnames = append([]string{cert.Subject.CommonName}, dnsnames...)\n+\t}\n+\n+\t// turn the DNS names into IPs\n+\tfor _, n := range dnsnames {\n+\t\t// see which resolve from here\n+\t\tips, _ := net.LookupIP(n)\n+\t\tif len(ips) == 0 {\n+\t\t\tlog.Debugf(\"Discarding name from viable set: %s\", n)\n+\t\t\tcontinue\n \n-\t\t_, err := cert.Verify(opts)\n-\t\tif err == nil {\n-\t\t\t// this identifier will work\n-\t\t\tlog.Debugf(\"Matched %s for use against host certificate\", n)\n-\t\t\t// trim '.' fqdn suffix if fqdn\n-\t\t\treturn strings.TrimSuffix(n, \".\"), nil\n \t\t}\n \n-\t\tlog.Debugf(\"Checked %s, no match for host cert\", n)\n+\t\tcandidateIPs = append(candidateIPs, ips...)\n \t}\n \n-\t// no viable address\n-\treturn ip, errors.New(\"unable to determine viable address\")\n+\t// always add all the altname IPs - we're not checking for connectivity\n+\tcandidateIPs = append(candidateIPs, cert.IPAddresses...)\n+\n+\treturn addrToUse(candidateIPs, cert, cas)","path":"lib/install/management/dispatcher.go","position":110,"original_position":110,"commit_id":"b3b79f7349aea4c59352e1264953f0f488ecebff","original_commit_id":"5861e4163a75cc7aef9a2c65d5907ea99fd5d769","user":{"login":"hickeng","id":3923729,"avatar_url":"https://avatars.githubusercontent.com/u/3923729?v=3","gravatar_id":"","url":"https://api.github.com/users/hickeng","html_url":"https://github.com/hickeng","followers_url":"https://api.github.com/users/hickeng/followers","following_url":"https://api.github.com/users/hickeng/following{/other_user}","gists_url":"https://api.github.com/users/hickeng/gists{/gist_id}","starred_url":"https://api.github.com/users/hickeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickeng/subscriptions","organizations_url":"https://api.github.com/users/hickeng/orgs","repos_url":"https://api.github.com/users/hickeng/repos","events_url":"https://api.github.com/users/hickeng/events{/privacy}","received_events_url":"https://api.github.com/users/hickeng/received_events","type":"User","site_admin":false},"body":"We resolve the DNS names to IPs as a filter for which are valid at the location vic-machine is being run. We then use that set of possible IPs along with the certificates to see which addresses pass TLS validation.","created_at":"2016-10-17T21:23:01Z","updated_at":"2016-10-17T21:23:01Z","html_url":"https://github.com/vmware/vic/pull/2744#discussion_r83737144","pull_request_url":"https://api.github.com/repos/vmware/vic/pulls/2744","_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments/83737144"},"html":{"href":"https://github.com/vmware/vic/pull/2744#discussion_r83737144"},"pull_request":{"href":"https://api.github.com/repos/vmware/vic/pulls/2744"}}},"pull_request":{"url":"https://api.github.com/repos/vmware/vic/pulls/2744","id":89457217,"html_url":"https://github.com/vmware/vic/pull/2744","diff_url":"https://github.com/vmware/vic/pull/2744.diff","patch_url":"https://github.com/vmware/vic/pull/2744.patch","issue_url":"https://api.github.com/repos/vmware/vic/issues/2744","number":2744,"state":"closed","locked":false,"title":"Use TLS friendly addresses in inspect output [full ci]","user":{"login":"hickeng","id":3923729,"avatar_url":"https://avatars.githubusercontent.com/u/3923729?v=3","gravatar_id":"","url":"https://api.github.com/users/hickeng","html_url":"https://github.com/hickeng","followers_url":"https://api.github.com/users/hickeng/followers","following_url":"https://api.github.com/users/hickeng/following{/other_user}","gists_url":"https://api.github.com/users/hickeng/gists{/gist_id}","starred_url":"https://api.github.com/users/hickeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickeng/subscriptions","organizations_url":"https://api.github.com/users/hickeng/orgs","repos_url":"https://api.github.com/users/hickeng/repos","events_url":"https://api.github.com/users/hickeng/events{/privacy}","received_events_url":"https://api.github.com/users/hickeng/received_events","type":"User","site_admin":false},"body":"Attempts to determine the appropriate address to use based on the configured certificates.\r\nThis is necessary because with certificate validation happening you have to use the appropriate name/IP to connect to the system.\r\n\r\nThe primary effect here is that the vicadmin URL will be either IP or FQDN as needed\r\n\r\nFull CI because anything that changes vic-machine output is fraught with danger.\r\n\r\nTowards #2726\r\n","created_at":"2016-10-14T21:24:27Z","updated_at":"2016-10-17T21:23:01Z","closed_at":"2016-10-17T21:09:53Z","merged_at":"2016-10-17T21:09:53Z","merge_commit_sha":"e9ae981446d5203a08eec13d53facac71fae4c3c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/vmware/vic/pulls/2744/commits","review_comments_url":"https://api.github.com/repos/vmware/vic/pulls/2744/comments","review_comment_url":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vmware/vic/issues/2744/comments","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/b3b79f7349aea4c59352e1264953f0f488ecebff","head":{"label":"hickeng:2726","ref":"2726","sha":"b3b79f7349aea4c59352e1264953f0f488ecebff","user":{"login":"hickeng","id":3923729,"avatar_url":"https://avatars.githubusercontent.com/u/3923729?v=3","gravatar_id":"","url":"https://api.github.com/users/hickeng","html_url":"https://github.com/hickeng","followers_url":"https://api.github.com/users/hickeng/followers","following_url":"https://api.github.com/users/hickeng/following{/other_user}","gists_url":"https://api.github.com/users/hickeng/gists{/gist_id}","starred_url":"https://api.github.com/users/hickeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickeng/subscriptions","organizations_url":"https://api.github.com/users/hickeng/orgs","repos_url":"https://api.github.com/users/hickeng/repos","events_url":"https://api.github.com/users/hickeng/events{/privacy}","received_events_url":"https://api.github.com/users/hickeng/received_events","type":"User","site_admin":false},"repo":{"id":55466787,"name":"vic","full_name":"hickeng/vic","owner":{"login":"hickeng","id":3923729,"avatar_url":"https://avatars.githubusercontent.com/u/3923729?v=3","gravatar_id":"","url":"https://api.github.com/users/hickeng","html_url":"https://github.com/hickeng","followers_url":"https://api.github.com/users/hickeng/followers","following_url":"https://api.github.com/users/hickeng/following{/other_user}","gists_url":"https://api.github.com/users/hickeng/gists{/gist_id}","starred_url":"https://api.github.com/users/hickeng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hickeng/subscriptions","organizations_url":"https://api.github.com/users/hickeng/orgs","repos_url":"https://api.github.com/users/hickeng/repos","events_url":"https://api.github.com/users/hickeng/events{/privacy}","received_events_url":"https://api.github.com/users/hickeng/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hickeng/vic","description":"Integrated containers on vSphere","fork":true,"url":"https://api.github.com/repos/hickeng/vic","forks_url":"https://api.github.com/repos/hickeng/vic/forks","keys_url":"https://api.github.com/repos/hickeng/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hickeng/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hickeng/vic/teams","hooks_url":"https://api.github.com/repos/hickeng/vic/hooks","issue_events_url":"https://api.github.com/repos/hickeng/vic/issues/events{/number}","events_url":"https://api.github.com/repos/hickeng/vic/events","assignees_url":"https://api.github.com/repos/hickeng/vic/assignees{/user}","branches_url":"https://api.github.com/repos/hickeng/vic/branches{/branch}","tags_url":"https://api.github.com/repos/hickeng/vic/tags","blobs_url":"https://api.github.com/repos/hickeng/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hickeng/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hickeng/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/hickeng/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hickeng/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/hickeng/vic/languages","stargazers_url":"https://api.github.com/repos/hickeng/vic/stargazers","contributors_url":"https://api.github.com/repos/hickeng/vic/contributors","subscribers_url":"https://api.github.com/repos/hickeng/vic/subscribers","subscription_url":"https://api.github.com/repos/hickeng/vic/subscription","commits_url":"https://api.github.com/repos/hickeng/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/hickeng/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/hickeng/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/hickeng/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/hickeng/vic/contents/{+path}","compare_url":"https://api.github.com/repos/hickeng/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hickeng/vic/merges","archive_url":"https://api.github.com/repos/hickeng/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hickeng/vic/downloads","issues_url":"https://api.github.com/repos/hickeng/vic/issues{/number}","pulls_url":"https://api.github.com/repos/hickeng/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/hickeng/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/hickeng/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hickeng/vic/labels{/name}","releases_url":"https://api.github.com/repos/hickeng/vic/releases{/id}","deployments_url":"https://api.github.com/repos/hickeng/vic/deployments","created_at":"2016-04-05T04:09:15Z","updated_at":"2016-04-05T04:09:16Z","pushed_at":"2016-10-17T21:08:29Z","git_url":"git://github.com/hickeng/vic.git","ssh_url":"git@github.com:hickeng/vic.git","clone_url":"https://github.com/hickeng/vic.git","svn_url":"https://github.com/hickeng/vic","homepage":null,"size":30484,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"vmware:master","ref":"master","sha":"2a2a841b0b40c7ee1ea5b4817bddaeaba94b0ce3","user":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"repo":{"id":49597898,"name":"vic","full_name":"vmware/vic","owner":{"login":"vmware","id":473334,"avatar_url":"https://avatars.githubusercontent.com/u/473334?v=3","gravatar_id":"","url":"https://api.github.com/users/vmware","html_url":"https://github.com/vmware","followers_url":"https://api.github.com/users/vmware/followers","following_url":"https://api.github.com/users/vmware/following{/other_user}","gists_url":"https://api.github.com/users/vmware/gists{/gist_id}","starred_url":"https://api.github.com/users/vmware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vmware/subscriptions","organizations_url":"https://api.github.com/users/vmware/orgs","repos_url":"https://api.github.com/users/vmware/repos","events_url":"https://api.github.com/users/vmware/events{/privacy}","received_events_url":"https://api.github.com/users/vmware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/vmware/vic","description":"Integrated containers engine on vSphere","fork":false,"url":"https://api.github.com/repos/vmware/vic","forks_url":"https://api.github.com/repos/vmware/vic/forks","keys_url":"https://api.github.com/repos/vmware/vic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vmware/vic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vmware/vic/teams","hooks_url":"https://api.github.com/repos/vmware/vic/hooks","issue_events_url":"https://api.github.com/repos/vmware/vic/issues/events{/number}","events_url":"https://api.github.com/repos/vmware/vic/events","assignees_url":"https://api.github.com/repos/vmware/vic/assignees{/user}","branches_url":"https://api.github.com/repos/vmware/vic/branches{/branch}","tags_url":"https://api.github.com/repos/vmware/vic/tags","blobs_url":"https://api.github.com/repos/vmware/vic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vmware/vic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vmware/vic/git/refs{/sha}","trees_url":"https://api.github.com/repos/vmware/vic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vmware/vic/statuses/{sha}","languages_url":"https://api.github.com/repos/vmware/vic/languages","stargazers_url":"https://api.github.com/repos/vmware/vic/stargazers","contributors_url":"https://api.github.com/repos/vmware/vic/contributors","subscribers_url":"https://api.github.com/repos/vmware/vic/subscribers","subscription_url":"https://api.github.com/repos/vmware/vic/subscription","commits_url":"https://api.github.com/repos/vmware/vic/commits{/sha}","git_commits_url":"https://api.github.com/repos/vmware/vic/git/commits{/sha}","comments_url":"https://api.github.com/repos/vmware/vic/comments{/number}","issue_comment_url":"https://api.github.com/repos/vmware/vic/issues/comments{/number}","contents_url":"https://api.github.com/repos/vmware/vic/contents/{+path}","compare_url":"https://api.github.com/repos/vmware/vic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vmware/vic/merges","archive_url":"https://api.github.com/repos/vmware/vic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vmware/vic/downloads","issues_url":"https://api.github.com/repos/vmware/vic/issues{/number}","pulls_url":"https://api.github.com/repos/vmware/vic/pulls{/number}","milestones_url":"https://api.github.com/repos/vmware/vic/milestones{/number}","notifications_url":"https://api.github.com/repos/vmware/vic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vmware/vic/labels{/name}","releases_url":"https://api.github.com/repos/vmware/vic/releases{/id}","deployments_url":"https://api.github.com/repos/vmware/vic/deployments","created_at":"2016-01-13T19:53:57Z","updated_at":"2016-10-15T04:26:16Z","pushed_at":"2016-10-17T21:22:19Z","git_url":"git://github.com/vmware/vic.git","ssh_url":"git@github.com:vmware/vic.git","clone_url":"https://github.com/vmware/vic.git","svn_url":"https://github.com/vmware/vic","homepage":"","size":83670,"stargazers_count":141,"watchers_count":141,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":53,"mirror_url":null,"open_issues_count":460,"forks":53,"open_issues":460,"watchers":141,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vmware/vic/pulls/2744"},"html":{"href":"https://github.com/vmware/vic/pull/2744"},"issue":{"href":"https://api.github.com/repos/vmware/vic/issues/2744"},"comments":{"href":"https://api.github.com/repos/vmware/vic/issues/2744/comments"},"review_comments":{"href":"https://api.github.com/repos/vmware/vic/pulls/2744/comments"},"review_comment":{"href":"https://api.github.com/repos/vmware/vic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vmware/vic/pulls/2744/commits"},"statuses":{"href":"https://api.github.com/repos/vmware/vic/statuses/b3b79f7349aea4c59352e1264953f0f488ecebff"}}}}
{"actor":{"display_login":"hickeng"}}