当前位置: 首页 > article >正文

ubuntu 14.04的git 错误: gnutls_handshake() failed: Handshake failed

文章目录

    • 篇头
    • 错误提示
    • 错误原因
    • 解决方法

篇头

最近使用ubuntu14.04,搭配gitlab出现此gnutls_handshake() failed: Handshake failed问题,一直未能解决,直到找到本文的脚本,修正编译错误后,终于得以解决。记录一下,分享给大家。

错误提示

fatal: unable to access 'https://192.168.31.187/aw/android.git/': gnutls_handshake() failed: Handshake failed

错误原因

  • git工具默认使用gnutls包进行网络加密传输,但在特殊情况下(如使用了代理服务器)gnutls会出现奇怪的问题,我们可以使用更稳定的openssl包来代替gnutils的功能。
  • 只有在低版本Ubuntu 14.04上遇到此问题,其余版本20.04及以上未有遇到

解决方法

  • 如下,直接使用此脚本,已在原版上增加CFLAGS=-std=gnu99,亲测OK
#!/usr/bin/env bash
set -eu
# Gather command line options
SKIPTESTS=
BUILDDIR=
SKIPINSTALL=
for i in "$@"; do 
  case $i in 
    -skiptests|--skip-tests) # Skip tests portion of the build
    SKIPTESTS=YES
    shift
    ;;
    -d=*|--build-dir=*) # Specify the directory to use for the build
    BUILDDIR="${i#*=}"
    shift
    ;;
    -skipinstall|--skip-install) # Skip dpkg install
    SKIPINSTALL=YES
    ;;
    *)
    #TODO Maybe define a help section?
    ;;
  esac
done

# Use the specified build directory, or create a unique temporary directory
set -x
BUILDDIR=${BUILDDIR:-$(mktemp -d)}
mkdir -p "${BUILDDIR}"
cd "${BUILDDIR}"

# Download the source tarball from GitHub
sudo apt-get update
sudo apt-get install curl jq -y
git_tarball_url="$(curl --retry 5 "https://api.github.com/repos/git/git/tags" | jq -r '.[0].tarball_url')"
curl -L --retry 5 "${git_tarball_url}" --output "git-source.tar.gz"
tar -xf "git-source.tar.gz" --strip 1

# Source dependencies
# Don't use gnutls, this is the problem package.
if sudo apt-get remove --purge libcurl4-gnutls-dev -y; then
  # Using apt-get for these commands, they're not supported with the apt alias on 14.04 (but they may be on later systems)
  sudo apt-get autoremove -y
  sudo apt-get autoclean
fi
# Meta-things for building on the end-user's machine
sudo apt-get install build-essential autoconf dh-autoreconf -y
# Things for the git itself
sudo apt-get install libcurl4-openssl-dev tcl-dev gettext asciidoc libexpat1-dev libz-dev -y

# Build it!
make configure
# --prefix=/usr
#    Set the prefix based on this decision tree: https://i.stack.imgur.com/BlpRb.png
#    Not OS related, is software, not from package manager, has dependencies, and built from source => /usr
# --with-openssl
#    Running ripgrep on configure shows that --with-openssl is set by default. Since this could change in the
#    future we do it explicitly
./configure --prefix=/usr --with-openssl 
make CFLAGS=-std=gnu99
if [[ "${SKIPTESTS}" != "YES" ]]; then
  make test CFLAGS=-std=gnu99
fi

# Install
if [[ "${SKIPINSTALL}" != "YES" ]]; then
  # If you have an apt managed version of git, remove it
  if sudo apt-get remove --purge git -y; then
    sudo apt-get autoremove -y
    sudo apt-get autoclean
  fi
  # Install the version we just built
  sudo make install  CFLAGS=-std=gnu99 #install-doc install-html install-info
  echo "Make sure to refresh your shell!"
  bash -c 'echo "$(which git) ($(git --version))"'
fi

http://www.kler.cn/a/161868.html

相关文章:

  • kafka面试题解答(四)
  • 某app最新版 vmp算法分析一
  • MacOS 本地生成SSH key并关联Github
  • 论文阅读《BEVFormer v2》
  • python: postgreSQL using psycopg2 or psycopg
  • 随手记:简单实现纯前端文件导出(XLSX)
  • 华为云安全组规则
  • Android 11.0 MTK Camera2 设置默认拍照尺寸功能实现
  • vue3日常知识点学习归纳
  • 第 7 部分 — 增强 LLM 安全性的策略:数学和伦理框架
  • 微前端 -- wujie 预加载和原理 无界传参
  • 探索图像生成中的生成对抗网络 (GAN) 世界
  • 唯创知音WTV380语音芯片高品质声音播放提示IC在骨盆按摩器上的应用介绍
  • 1、命名空间、C++的复合类型、缺省参数
  • 精通Nginx(21)-大幅度提升性能优化方法
  • 石头剪刀布python
  • TCP通信
  • qt中sokect断开的几种情况
  • keil添加了头文件仍然报找不到头文件的原因
  • 4-Docker命令之docker stop
  • Apache Flink(九):集群基础环境搭建-Centos7节点配置
  • LeetCode 每日一题 Day 6(DFS+BFS)
  • ChatGPT在国内的使用限制,国内的ChatGPT替代工具
  • C#winform上下班打卡系统Demo
  • 基于AWS Serverless的Glue服务进行ETL(提取、转换和加载)数据分析(一)——创建Glue
  • 两个分数相加。