TerminalFi / LSP-copilot

GitHub Copilot support for Sublime Text LSP plugin provided through Copilot.vim.
625 stars 25 forks source link

Unable to get issuer cert locally #65

Closed JulienDeveaux closed 1 year ago

JulienDeveaux commented 1 year ago

Hi,

I have trouble logging to copilot because of my corporate network messing up SSL certificate checks.

Here are the logs of LSP

:: --> LSP-copilot initialize(1): {'rootUri': None, 'processId': 16896, 'workspaceFolders': None, 'clientInfo': {'version': '1.20.0', 'name': 'Sublime Text LSP'}, 'rootPath': None, 'capabilities': {'textDocument': {'colorProvider': {'dynamicRegistration': True}, 'typeDefinition': {'dynamicRegistration': True, 'linkSupport': True}, 'references': {'dynamicRegistration': True}, 'hover': {'dynamicRegistration': True, 'contentFormat': ['markdown', 'plaintext']}, 'rangeFormatting': {'dynamicRegistration': True}, 'documentSymbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [8, 12, 11, 13, 9, 21, 14, 1, 25, 18, 3, 6, 7, 10, 24, 4, 17, 26, 23, 19, 20, 5, 2, 16, 22, 15]}, 'tagSupport': {'valueSet': [1]}, 'hierarchicalDocumentSymbolSupport': True}, 'declaration': {'dynamicRegistration': True, 'linkSupport': True}, 'completion': {'completionItemKind': {'valueSet': [5, 3, 8, 6, 4, 21, 17, 24, 2, 18, 10, 15, 13, 1, 23, 19, 16, 14, 11, 22, 25, 7, 9, 20, 12]}, 'dynamicRegistration': True, 'insertTextMode': 2, 'completionItem': {'insertTextModeSupport': {'valueSet': [2]}, 'snippetSupport': True, 'resolveSupport': {'properties': ['detail', 'documentation', 'additionalTextEdits']}, 'insertReplaceSupport': True, 'deprecatedSupport': True, 'documentationFormat': ['markdown', 'plaintext'], 'labelDetailsSupport': True, 'tagSupport': {'valueSet': [1]}}}, 'signatureHelp': {'dynamicRegistration': True, 'signatureInformation': {'activeParameterSupport': True, 'parameterInformation': {'labelOffsetSupport': True}, 'documentationFormat': ['markdown', 'plaintext']}, 'contextSupport': True}, 'documentLink': {'dynamicRegistration': True, 'tooltipSupport': True}, 'implementation': {'dynamicRegistration': True, 'linkSupport': True}, 'codeLens': {'dynamicRegistration': True}, 'formatting': {'dynamicRegistration': True}, 'documentHighlight': {'dynamicRegistration': True}, 'publishDiagnostics': {'relatedInformation': True, 'versionSupport': True, 'dataSupport': True, 'tagSupport': {'valueSet': [1, 2]}, 'codeDescriptionSupport': True}, 'semanticTokens': {'formats': ['relative'], 'multilineTokenSupport': True, 'augmentsSyntaxTokens': True, 'dynamicRegistration': True, 'tokenTypes': ['function', 'interface', 'variable', 'parameter', 'regexp', 'decorator', 'typeParameter', 'operator', 'modifier', 'namespace', 'method', 'macro', 'enum', 'event', 'comment', 'property', 'keyword', 'struct', 'type', 'class', 'number', 'enumMember', 'string'], 'requests': {'full': {'delta': True}, 'range': True}, 'tokenModifiers': ['readonly', 'abstract', 'defaultLibrary', 'definition', 'deprecated', 'modification', 'declaration', 'async', 'documentation', 'static'], 'overlappingTokenSupport': False}, 'codeAction': {'dataSupport': True, 'codeActionLiteralSupport': {'codeActionKind': {'valueSet': ['quickfix', 'refactor', 'refactor.extract', 'refactor.inline', 'refactor.rewrite', 'source.fixAll', 'source.organizeImports']}}, 'resolveSupport': {'properties': ['edit']}, 'isPreferredSupport': True, 'dynamicRegistration': True, 'disabledSupport': True}, 'definition': {'dynamicRegistration': True, 'linkSupport': True}, 'selectionRange': {'dynamicRegistration': True}, 'inlayHint': {'dynamicRegistration': True, 'resolveSupport': {'properties': ['textEdits', 'label.command']}}, 'rename': {'dynamicRegistration': True, 'prepareSupport': True}, 'synchronization': {'willSaveWaitUntil': True, 'dynamicRegistration': True, 'willSave': True, 'didSave': True}}, 'workspace': {'codeLens': {'refreshSupport': True}, 'didChangeConfiguration': {'dynamicRegistration': True}, 'workspaceEdit': {'documentChanges': True, 'failureHandling': 'abort'}, 'workspaceFolders': True, 'inlayHint': {'refreshSupport': True}, 'semanticTokens': {'refreshSupport': True}, 'applyEdit': True, 'executeCommand': {}, 'symbol': {'dynamicRegistration': True, 'symbolKind': {'valueSet': [8, 12, 11, 13, 9, 21, 14, 1, 25, 18, 3, 6, 7, 10, 24, 4, 17, 26, 23, 19, 20, 5, 2, 16, 22, 15]}, 'tagSupport': {'valueSet': [1]}}, 'configuration': True}, 'window': {'workDoneProgress': True, 'showMessage': {'messageActionItem': {'additionalPropertiesSupport': True}}, 'showDocument': {'support': True}}, 'general': {'regularExpressions': {'engine': 'ECMAScript'}, 'markdown': {'parser': 'Python-Markdown', 'version': '3.2.2'}}}, 'initializationOptions': {}}
:: <?  LSP-copilot LogMessage: {'metadataStr': '[DEBUG] [agent] [2022-11-07T09:41:38.038Z]', 'message': '[DEBUG] [agent] [2022-11-07T09:41:38.038Z] Agent service starting', 'extra': ['Agent service starting'], 'level': 0}
:: <-- LSP-copilot client/registerCapability(0): {'registrations': [{'id': '117fe942-b603-4845-86cf-d9467ef7c45b', 'method': 'workspace/didChangeWorkspaceFolders', 'registerOptions': {}}]}
:: >>> LSP-copilot 0: None
:: <<< LSP-copilot 1: {'capabilities': {'workspace': {'workspaceFolders': {'changeNotifications': True, 'supported': True}}, 'textDocumentSync': {'change': {'syncKind': 2}, 'didOpen': {}, 'didClose': {}}}}
::  -> LSP-copilot initialized: {}
::  -> LSP-copilot workspace/didChangeConfiguration: {'settings': {'debug': True, 'completion_style': 'popup', 'auto_ask_completions': True, 'hook_to_auto_complete_command': False, 'telemetry': False, 'local_checks': False}}
:: --> LSP-copilot checkStatus(2): {}
:: --> LSP-copilot setEditorInfo(3): {'editorPluginInfo': {'version': '0.1.10', 'name': 'LSP-copilot'}, 'editorInfo': {'version': '4126', 'name': 'Sublime Text'}}
::  -> LSP-copilot textDocument/didOpen: {'textDocument': {'uri': 'buffer://sublime/59', 'languageId': 'txt', 'version': 0, 'text': ''}}
:: <-  LSP-copilot LogMessage: {'metadataStr': '[DEBUG] [agent] [2022-11-07T09:41:38.329Z]', 'message': '[DEBUG] [agent] [2022-11-07T09:41:38.329Z] Telemetry initialized', 'extra': ['Telemetry initialized'], 'level': 0}
:: <<< LSP-copilot 3: 'OK'
:: <<< LSP-copilot 2: {'status': 'NotSignedIn'}
:: --> LSP-copilot signInInitiate(4): {}
:: <<< LSP-copilot 4: {'expiresIn': 899, 'status': 'PromptUserDeviceFlow', 'interval': 5, 'userCode': 'C6BE-6B1F', 'verificationUri': 'https://github.com/login/device'}
:: --> LSP-copilot signInConfirm(5): {'userCode': 'C6BE-6B1F'}
LSP-copilot: unhandledRejection {"type":"system","errno":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY","code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"}
jfcherng commented 1 year ago

You may try to use the following plugin settings for LSP-copilot:

    "env": {
        "NODE_TLS_REJECT_UNAUTHORIZED": "0",
    },
JulienDeveaux commented 1 year ago

Still the same error :/

My config file:

{

    "env": {
        "NODE_TLS_REJECT_UNAUTHORIZED": "0",
    },
        "command": [
        "${node_bin}",
        "${server_path}",
        "--stdio"
    ],
    "schemes": [
        "file",
        "buffer",
        "res"
    ],
    "settings": {
        "auto_ask_completions": true,
        "debug": true,
        "hook_to_auto_complete_command": false,
        "local_checks": false,
        "telemetry": false,
        "completion_style": "popup"
    },
    // ST4 configuration
    "selector": "source | text | embedding"
}

LSP logs:

LSP-copilot: (node:3496) Warning: Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to '0' makes TLS connections and HTTPS requests insecure by disabling certificate verification.
LSP-copilot: (Use `node.EXE --trace-warnings ...` to show where the warning was created)
:: <-  LSP-copilot LogMessage: {'message': '[DEBUG] [agent] [2022-11-07T13:04:24.896Z] Telemetry initialized', 'metadataStr': '[DEBUG] [agent] [2022-11-07T13:04:24.896Z]', 'level': 0, 'extra': ['Telemetry initialized']}
:: <<< LSP-copilot 3: 'OK'
:: <<< LSP-copilot 2: {'status': 'NotSignedIn'}
:: --> LSP-copilot signInInitiate(4): {}
:: <<< LSP-copilot 4: {'verificationUri': 'https://github.com/login/device', 'status': 'PromptUserDeviceFlow', 'userCode': '02C9-DE8E', 'expiresIn': 899, 'interval': 5}
:: --> LSP-copilot signInConfirm(5): {'userCode': '02C9-DE8E'}
LSP-copilot: unhandledRejection {"type":"system","errno":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY","code":"UNABLE_TO_GET_ISSUER_CERT_LOCALLY"}
TerminalFi commented 1 year ago

The other env would be to use NODE_EXTRA_CA_CERTS="absolute_path_to_your_certificates.pem"

jfcherng commented 1 year ago

yet another to try:

    "command": [
        "${node_bin}",
        "${server_path}",
        "--use-bundled-ca",
        "--stdio"
    ],
JulienDeveaux commented 1 year ago

I tryed the new command but it has the same issue.

For the env environment I'm in trouble as I don't know where to get the pem file

jfcherng commented 1 year ago

For the env environment I'm in trouble as I don't know where to get the pem file

may use the one from cURL: https://curl.se/ca/cacert.pem

JulienDeveaux commented 1 year ago

I already tryed this one and one generated from the openssl command but I am in a corporate network under zscaler so I think it has specific certificates

jfcherng commented 1 year ago

what if run npm -g config set strict-ssl false in cmd/powershell and restart ST ?

JulienDeveaux commented 1 year ago

Doesn't change with npm -g config set strict-ssl false

jfcherng commented 1 year ago

It looks like there is a ZscalerRootCertificate-2048-SHA256.crt file somewhere.

https://community.zscaler.com/t/installing-tls-ssl-root-certificates-to-non-standard-environments/7261?page=2

JulienDeveaux commented 1 year ago

Yeah but the NODE_EXTRA_CA_CERTS="absolute_path_to_your_certificates.pem" take a .pem file not a crt :/

jfcherng commented 1 year ago

Yeah but the NODE_EXTRA_CA_CERTS="absolute_path_to_your_certificates.pem" take a .pem file not a crt :/

It seems fine with .crt too.

JulienDeveaux commented 1 year ago

It's indeed working 🎉🎉

Thank you a lot ^^