OpenSSL安装

安装OpenSSL

安装OpenSSL

OpenEuler系统中已经安装好了OpenSSL,下面直接开始测试

  • 查看版本

image

  • OpenSSL命令
    • 标准命令
    • 消息摘要命令
    • 密码命令
  • 测试
    1. 简单测试

      代码:

      /*testOpenSSL.c*/
      #include <stdio.h>
      #include <openssl/evp.h>
      
      int main(){
      	
          OpenSSL_add_all_algorithms();
      	
          return 0;
      }
      
      

      遇到问题:编译时出现报错

      image

      分析应该是路径问题,查找openssl库文件路径,发现此时没有对应库文件。重新安装。

      安装过程如下:

      1. 使用wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz下载源码

        image

      2. 使用tar -zxvf openssl-1.1.1l.tar.gz -C OpenSSLsrc命令解压源码

      3. 进入OpenSSLsrc/openssl-1.1.1l目录,使用./config --prefix=/root/myopenssl命令设置编译安装路径

      image

      1. 编译、测试、安装

        使用make命令进行编译

        image

      image

      等待一会完成编译后,使用make test命令进行测试

      image

      image

      1. 最后使用make install进行安装

        image

测试OpenSSL

OpenSSL命令的使用

  1. 使用openssl help查看帮助文档

    image

  2. OpenSSL命令

    • 标准命令
    • 消息摘要命令
    • 密码命令
    1. 使用openssl version查看版本的两种方法

      image

    2. liuxinyu放到20191312.txt文件中,计算文件的摘要:

      image

OpenSSL编程

  1. 简单测试

    代码

    /*testOpenSSL.c*/
    #include <stdio.h>
    #include <openssl/evp.h>
    
    int main(){
    	
        OpenSSL_add_all_algorithms();
    	
        return 0;
    }
    

    使用gcc -o bin/testOpenSSL src/testOpenSSL.c -I /root/myopenssl/include -L /root/myopenssl/lib -lcrypto -lpthread命令编译并使用bin/testOpenSSL;echo $?命令运行。

    image

posted @ 2021-11-02 19:22  PuTa0  阅读(1976)  评论(0编辑  收藏  举报