Title: Getting an SSL error when querying project · python-gitlab/python-gitlab · Discussion #3212 · GitHub
Open Graph Title: Getting an SSL error when querying project · python-gitlab/python-gitlab · Discussion #3212
X Title: Getting an SSL error when querying project · python-gitlab/python-gitlab · Discussion #3212
Description: Getting an SSL error when querying project
Open Graph Description: Hi! I've been playing around with the library against a self hosted GitLab instance and it has worked without issue every time until recently, where, without changing the code, I started getting th...
X Description: Hi! I've been playing around with the library against a self hosted GitLab instance and it has worked without issue every time until recently, where, without changing the code, I started gettin...
Opengraph URL: https://github.com/python-gitlab/python-gitlab/discussions/3212
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Getting an SSL error when querying project","text":"Hi!
\nI've been playing around with the library against a self hosted GitLab instance and it has worked without issue every time until recently, where, without changing the code, I started getting this error for all interactions with a project.
\nrequests.exceptions.SSLError: HTTPSConnectionPool(host='gitlab.example.com', port=80): Max retries exceeded with url: /api/v4/projects/5/labels?id=5&include_ancestor_groups=true&page=2&per_page=20&with_counts=false (Caused by SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1028)')))\n
\nI can't figure out if it's something I've done somehow, but I don't think I touched anything.
\nFor context, I'm sitting behind a VPN and the target instance is served through HTTPS with an NGINX reverse proxy in the middle
","upvoteCount":1,"answerCount":2,"acceptedAnswer":{"@type":"Answer","text":"I found out the root cause by printing the server responses from within the urllib library:
\nUserWarning: The base URL in the server response differs from the user-provided base URL (https://gitlab.example.com:443 -> https://gitlab.example.com:80)\n
\nSo it was a configuration issue, I had this in my compose.yaml:
\nservices:\n gitlab:\n image: gitlab/gitlab-ee:18.0.1-ee.0\n container_name: gitlab\n restart: always\n hostname: '$HOSTNAME'\n environment:\n GITLAB_OMNIBUS_CONFIG: |\n # Add any other gitlab.rb configuration here, each on its own line\n # I'm including only relevant configs here\n external_url 'http://$HOSTNAME'\n ports:\n - '$SSH_PORT:22'\n volumes:\n - '$GITLAB_HOME/config:/etc/gitlab'\n - '$GITLAB_HOME/logs:/var/log/gitlab'\n - '$GITLAB_HOME/data:/var/opt/gitlab'\n shm_size: '256m'\n\nnetworks:\n default:\n external: true\n name: $NETWORK_NAME\n\n
\nI had the external URL as HTTP, consequently GitLab assumed port 80 and that's what it would respond with when asking for paginated endpoints (gitlab.example.com:80/api<...>) since it specifies the port there, of course that couldn't work when there's Nginx Proxy Manager in the middle configured for HTTPS, so I was missing a couple lines of configuration in the gitlab.rb (through GITLAB_OMNIBUS_CONFIG) found from this post https://serverfault.com/questions/1022717/using-gitlab-docker-behind-nginx-proxy-manager-docker
\nI put this in the variable, note the difference in external_url in particular with the added \"s\" to \"http\":
\nGITLAB_OMNIBUS_CONFIG: |\n # Add any other gitlab.rb configuration here, each on its own line\n # I'm including only relevant configs here\n external_url 'https://$HOSTNAME'\n nginx['listen_port'] = 80\n nginx['listen_https'] = false
\nAnd now it's all working correctly, GitLab responds with HTTPS endpoints.
\nNote: the reason why it worked until it didn't is that my requests initially didn't need pagination until I had added enough labels to the project, so it only used the URL I would provide, which also led me to believe there weren't problems with my input (which is true, the issue lies in the server response) when I tried to perform a manual connection as suggested by @JohnVillalovos to troubleshoot
","upvoteCount":1,"url":"https://github.com/python-gitlab/python-gitlab/discussions/3212#discussioncomment-13429879"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/:user_id/:repository/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:012b09b5-d492-5d8d-c898-a3996210f924 |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | A2DE:3914B5:11A0578:17B3A9E:69732CB9 |
| html-safe-nonce | 15923ae7bfe7608dfc648d5f484a1c613b0d3f55bb96a254a4bb4ddaa979ece9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMkRFOjM5MTRCNToxMUEwNTc4OjE3QjNBOUU6Njk3MzJDQjkiLCJ2aXNpdG9yX2lkIjoiNTExNTM5MTY5NzI0ODAwNTMwNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 3702b3903926175159878cc4f4f390ca69c57bacacee8e7b0d49251ddb3f64dc |
| hovercard-subject-tag | discussion:8430351 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/python-gitlab/python-gitlab/3212/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/eec35e530ca96f39604c9f7833066284492fd898826a5bb2bd29a7b582ec5263/python-gitlab/python-gitlab/discussions/3212 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eec35e530ca96f39604c9f7833066284492fd898826a5bb2bd29a7b582ec5263/python-gitlab/python-gitlab/discussions/3212 |
| og:image:alt | Hi! I've been playing around with the library against a self hosted GitLab instance and it has worked without issue every time until recently, where, without changing the code, I started getting th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 44ab3188c1dcfe3be0f9c3feca2e04e14fb79f120939ce2395e4f15ab96ec1d4 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-gitlab/python-gitlab git https://github.com/python-gitlab/python-gitlab.git |
| octolytics-dimension-user_id | 28886265 |
| octolytics-dimension-user_login | python-gitlab |
| octolytics-dimension-repository_id | 8077625 |
| octolytics-dimension-repository_nwo | python-gitlab/python-gitlab |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 8077625 |
| octolytics-dimension-repository_network_root_nwo | python-gitlab/python-gitlab |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | a5e2b48bd1260476599758f5d253b5d24092ab84 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width