def _get_tls_pymongo_options(self, args):
        opts = {}
        if not self.tls_server_args:
            return opts

        for parser in [self.tls_server_args]:
            for action in parser._group_actions:
                name = action.dest
                value = args.get(name)
                if value:
                    opts['tls'] = True
                    opts['tls_cert_reqs'] = ssl.CERT_NONE
        for parser in self.tls_args, self.tls_client_args:
            for action in parser._group_actions:
                name = action.dest
                value = args.get(name)
                if value:
                    opts['tls'] = True

                    # TLS parameters require PyMongo 3.9.0+
                    # https://api.mongodb.com/python/3.9.0/changelog.html
                    if name == 'tlsCertificateKeyFile':
                        opts['tlsCertificateKeyFile'] = value
                    elif name == 'tlsCertificateKeyFilePassword':
                        opts['tlsCertificateKeyFilePassword'] = value
                    elif name == 'tlsAllowInvalidCertificates':
                        opts['tlsAllowInvalidCertificates'] = ssl.CERT_OPTIONAL
                    elif name == 'tlsAllowInvalidHostnames':
                        opts['tlsAllowInvalidHostnames'] = False
                    elif name == 'tlsCAFile':
                        opts['tlsCAFile'] = value
                    elif name == 'tlsCRLFile':
                        opts['tlsCRLFile'] = value

        return opts