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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM