# Buggy code
def _get_options(ret=None):
    """
    Returns options used for the MySQL connection.
    """
    defaults = {
        "host": "salt",
        "user": "salt",
        "pass": "salt",
        "db": "salt",
        "port": 3306,
        "ssl_ca": None,
        "ssl_cert": None,
        "ssl_key": None,
    }

    attrs = {
        "host": "host",
        "user": "user",
        "pass": "pass",
        "db": "db",
        "port": "port",
        "ssl_ca": "ssl_ca",
        "ssl_cert": "ssl_cert",
        "ssl_key": "ssl_key",
    }

    _options = salt.returners.get_returner_options(
        __virtualname__,
        ret,
        attrs,
        __salt__=__salt__,
        __opts__=__opts__,
        defaults=defaults,
    )
    # Ensure port is an int
    if "port" in _options:
        _options["port"] = int(_options["port"])
    return _options


# Traceback (salt.exceptions.SaltMasterError)
Sep 29 21:15:20 salt salt-master[2529]: [ERROR   ] Error in function _return:
Sep 29 21:15:20 salt salt-master[2529]: Traceback (most recent call last):
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1558, in run_func
Sep 29 21:15:20 salt salt-master[2529]:     ret = getattr(self, func)(load)
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1371, in _return
Sep 29 21:15:20 salt salt-master[2529]:     self.opts, load, event=self.event, mminion=self.mminion)
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/dist-packages/salt/utils/job.py", line 49, in store_job
Sep 29 21:15:20 salt salt-master[2529]:     mminion.returners[saveload_fstr](load['jid'], load)
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 299, in save_load
Sep 29 21:15:20 salt salt-master[2529]:     with _get_serv(commit=True) as cur:
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/contextlib.py", line 17, in __enter__
Sep 29 21:15:20 salt salt-master[2529]:     return self.gen.next()
Sep 29 21:15:20 salt salt-master[2529]:   File "/usr/lib/python2.7/dist-packages/salt/returners/mysql.py", line 236, in _get_serv
Sep 29 21:15:20 salt salt-master[2529]:     raise salt.exceptions.SaltMasterError('MySQL returner could not connect to database: {exc}'.format(exc=exc))
Sep 29 21:15:20 salt salt-master[2529]: SaltMasterError: MySQL returner could not connect to database: (2026, "SSL connection error: SSL is required but the server doesn't support it")

# Fixed code
def _get_options(ret=None):
    """
    Returns options used for the MySQL connection.
    """
    defaults = {
        "host": "salt",
        "user": "salt",
        "pass": "salt",
        "db": "salt",
        "port": 3306,
        "ssl_ca": None,
        "ssl_cert": None,
        "ssl_key": None,
    }

    attrs = {
        "host": "host",
        "user": "user",
        "pass": "pass",
        "db": "db",
        "port": "port",
        "ssl_ca": "ssl_ca",
        "ssl_cert": "ssl_cert",
        "ssl_key": "ssl_key",
    }

    _options = salt.returners.get_returner_options(
        __virtualname__,
        ret,
        attrs,
        __salt__=__salt__,
        __opts__=__opts__,
        defaults=defaults,
    )
    # post processing
    for k, v in _options.iteritems():
        if isinstance(v, string_types) and v.lower() == "none":
            # Ensure 'None' is rendered as None
            _options[k] = None
        if k == "port":
            # Ensure port is an int
            _options[k] = int(v)

    return _options