Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to sign certificates for None if ip not resolved #733

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions charmhelpers/contrib/openstack/cert_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import os
import json
import socket
from base64 import b64decode

from charmhelpers.contrib.network.ip import (
Expand Down Expand Up @@ -86,11 +87,14 @@ def add_hostname_cn(self):
# If a vip is being used without os-hostname config or
# network spaces then we need to ensure the local units
# cert has the appropriate vip in the SAN list
vip = get_vip_in_network(resolve_network_cidr(ip))
try:
vip = get_vip_in_network(resolve_network_cidr(ip))
except:
vip = None
if vip:
addresses.append(vip)
self.hostname_entry = {
'cn': get_hostname(ip),
'cn': get_hostname(ip) or socket.getfqdn(),
'addresses': addresses}

def add_hostname_cn_ip(self, addresses):
Expand Down Expand Up @@ -156,7 +160,10 @@ def get_certificate_request(json_encode=True, bindings=None):
net_addr = None
ip = network_get_primary_address(binding)
addresses = [net_addr, ip]
vip = get_vip_in_network(resolve_network_cidr(ip))
try:
vip = get_vip_in_network(resolve_network_cidr(ip))
except:
vip = None
if vip:
addresses.append(vip)

Expand Down Expand Up @@ -217,7 +224,10 @@ def get_certificate_sans(bindings=None):
net_addr = None
ip = get_relation_ip(binding, cidr_network=net_config)
_sans = _sans + [net_addr, ip]
vip = get_vip_in_network(resolve_network_cidr(ip))
try:
vip = get_vip_in_network(resolve_network_cidr(ip))
except:
vip = None
if vip:
_sans.append(vip)
# Clear any Nones and duplicates
Expand Down