OpenSSL ์ปดํŒŒ์ผ(compile) & ๋นŒ๋“œ(build)


๊ฐœ์š”

OpenSSL ์€ Eric A. Young ์ด ๋งŒ๋“  SSLeay ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์ƒ์šฉ์ˆ˜์ค€์˜ ๋ฐ์ดํƒ€์•”๋ณตํ˜ธ/SSL/TLS ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ํ”„๋กœ์ ํŠธ์ด๋‹ค.

Linux ๋ผ๋ฉด apt-get์ด๋‚˜ yum ์œผ๋กœ ํ•œ๋ฐฉ์— ์„ค์น˜ ๊ฐ€๋Šฅํ•˜์ง€๋งŒ Un*x ๋‚˜ Windows ์—์„œ๋Š” ์ปดํŒŒ์ผ ํ•  ์ผ์ด ๊ฐ€๋” ์ƒ๊ฒจ์„œ ๋นŒ๋“œ ๋ฐฉ๋ฒ•์„ ์ •๋ฆฌํ•ด ๋ณธ๋‹ค.

๋นŒ๋“œ ์‚ฌ์ „ ์ค€๋น„

  • C/C++ Compiler๊ฐ€ ํ•„์š”ํ•˜๋‹ค. Windows ์—์„œ๋Š” Visual Studio 2010 Express ๋ฒ„์ „์„ ์‚ฌ์šฉํ•˜์˜€๊ณ  HP-UX ์—์„œ๋Š” aCC compiler ๋ฅผ ์‚ฌ์šฉํ•˜์˜€๋‹ค.
  • perl ์ด ํ•„์š”ํ•˜๋ฏ€๋กœ Windows๋Š”ย ActivePerlย ์ด๋‚˜ย Strawberry Perlย ์„ย ๋ฏธ๋ฆฌ ์„ค์น˜ํ•ด ๋†“๋Š”๋‹ค. (๋Œ€๊ฐœ์˜ Unix ๋Š” ๋ฏธ๋ฆฌ ์„ค์น˜๋˜์–ด ์žˆ๋‹ค.)

๋นŒ๋“œ

  • openssl ํ™ˆํŽ˜์ด์ง€์—์„œ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋‹ค์šด๋ฐ›๋Š”๋‹ค.
  • ์••์ถ•์„ ํ’€๊ณ  ๋‚˜์˜จ Install๋กœ ์‹œ์ž‘๋˜๋Š” ํŒŒ์ผ๋“ค์„ ์ฝ์–ด ๋ณธ๋‹ค. ํ”Œ๋žซํผ๋ณ„๋กœ ์กด์žฌํ•˜๋ฉฐ ํ™•์žฅ์ž์—๋Š” ํ”Œ๋žซํผ๋ช…์ด ์žˆ๋‹ค.ย 
    ์˜ˆ๋กœ Win32 ์—์„œ ๋นŒ๋“œํ•  ๊ฒฝ์šฐ Install.w32, Win64๋Š” Install.w64๋ฅผ ์ฐธ๊ณ ํ•˜๋ฉฐ Unix๋Š” Install ๋ฅผ ์ฝ์–ด ๋ณธ๋‹ค
  • perl ๋กœ ์ž‘์„ฑ๋œ ./Configure ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ˆ˜ํ–‰ํ•˜์—ฌ Makefile ์„ ์ƒ์„ฑํ•˜๊ณ  build ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•˜๊ฒŒ ๋œ๋‹ค.ย 
    ๊ธฐ๋ณธ์ ์œผ๋กœ static library ๋กœ ๋นŒ๋“œ๋˜๋ฏ€๋กœ dynamic library ๋กœ ๋นŒ๋“œํ•  ๊ฒฝ์šฐ shared ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•œ๋‹ค.


openssl ์—๋Š” ํŠนํ—ˆ๊ฐ€ ๊ฑธ๋ ค์žˆ๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์žˆ๋‹ค. ์˜ค๋ž˜๋˜์„œ ์ทจ์•ฝํ•˜๊ณ  ์“ธ ์ผ๋„ ์—†๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜๋“ค์ด๋ฏ€๋กœ ๋‹ค์Œ ์˜ต์…˜์„ ๊ผญ ์ถ”๊ฐ€ํ•ด์„œ build ์‹œ ์ œ์™ธ์‹œํ‚ค์ž.

no-idea no-md2 no-mdc2 no-rc5 no-rc4


Unix / Linux ๋นŒ๋“œ ๋ฐฉ๋ฒ•

  • ./Configure os-cpu-compiler ์ถ”๊ฐ€ ์˜ต์…˜์„ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋œ๋‹ค. ๋‹ค์Œ์€ HP-UX ์—์„œ 64bit ๋กœ dynamic library ๋กœ ์ปดํŒŒ์ผ ํ•˜๊ธฐ ์œ„ํ•œ ์„ค์ •์ด๋‹ค.
    ย 

    PARISC HP-UX ์—์„œ 64bit๋กœ ์ปดํŒŒ์ผ
    ./Configure hpux64-parisc2-cc shared no-md2 no-mdc2 no-rc5 no-rc4  no-asm --prefix=/usr/local
    Mac OSX์—์„œ 64bit๋กœ ์ปดํŒŒ์ผ
    ./Configure darwin-i386-cc shared no-md2 no-mdc2 no-rc5 no-rc4  --prefix=/usr/local
    Linux 64bit๋กœ ์ปดํŒŒ์ผ
    ./Configure linux-x86_64 shared  no-md2 no-mdc2 no-rc5 no-rc4  --prefix=/usr/local
  • OS์™€ compiler๋ฅผ ์ž˜ ๋ชจ๋ฅผ๊ฒฝ์šฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ./config ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ฉด ํ•ด๋‹น ์‹œ์Šคํ…œ์— ๋งž๊ฒŒ ์ž๋™์œผ๋กœ ์ง„ํ–‰ํ•œ๋‹ค.(๋ณดํ†ต 32bit ๋กœ build ํ•˜๋ฏ€๋กœ 64bit ๊ฐ€ ํ•„์š”ํ•  ๊ฒฝ์šฐ ์ˆ˜๋™์œผ๋กœ os/compiler ์ฃผ์–ด์•ผ ํ•œ๋‹ค.)
bash-4.2$ ./config    
Operating system: 9000/800-hp-hpux1x
WARNING! If you wish to build 64-bit library then you have to
         invoke './Configure hpux64-parisc2-cc' *manually*.
         You have about 5 seconds to press Ctrl-C to abort.
  • --prefix ์˜ต์…˜์„ ์ฃผ์ง€ ์•Š์œผ๋ฉด ๊ธฐ๋ณธ์ ์œผ๋กœ /usr/local/ ๋ฐ‘์— ๋‚˜๋ˆ ์„œ ๋“ค์–ด๊ฐ„๋‹ค. header (.h)๋Š” /usr/local/include/openssl, openssl ์‹คํ–‰ ํŒŒ์ผ์€ /usr/local/bin, library ๋Š” /usr/local/lib/openssl ํด๋”์— ์„ค์น˜๋œ๋‹ค.

    ๊ธฐ๋ณธ์ ์œผ๋กœ ์ •์  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(static library)๋กœ ์ปดํŒŒ์ผ๋˜๋ฉฐ ๋งŒ์•ฝ ๋™์  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ(shared library) ๋กœ ์ปดํŒŒ์ผํ•  ๊ฒฝ์šฐ ./config ์‹œ shared ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•œ๋‹ค. (๊ธฐ๋ณธ๊ฐ’ no-shared)

    ./config no-asm enable-seed enable-cms no-idea no-md2 no-md4 no-mdc2 no-rc2 no-rc4 no-rc5 no-zlib-dynamic
  • ์„ค์ •์ด ์™„๋ฃŒ๋˜์—ˆ์œผ๋ฉด make ๋ช…๋ น์–ด๋กœ ์ปดํŒŒ์ผํ•œ๋‹ค.

    make depend && make
    make test
    
  • ์ปดํŒŒ์ผ๋œ ํ”„๋กœ๊ทธ๋žจ๊ณผ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ/ํ—ค๋”๋ฅผ ์„ค์น˜ํ•œ๋‹ค. --prefix ๋กœ ๊ฒฝ๋กœ๋ฅผ ์ง€์ •ํ–ˆ์œผ๋ฏ€๋กœ ์„ค์น˜ ๊ฒฝ๋กœ๋Š” /usr/local/ssl ์ด ๋œ๋‹ค.

    make install


Windows ์šฉ ๋นŒ๋“œ ๋ฐฉ๋ฒ•

  • cmd๋ฅผ ์—ด๊ณ  Visual Studio ์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” vcvars32.bat๋ฅผ ์‹คํ–‰ํ•ด์„œ cmd์—์„œ Visual C++ Compiler๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ™˜๊ฒฝ ๋ณ€์ˆ˜๋ฅผ ์„ค์ •ํ•œ๋‹ค.
  • ๋‹ค์Œ ๋ช…๋ น์–ด๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.(--prefix ๋’ค์—๋Š” ์„ค์น˜๋  ๊ฒฝ๋กœ๋ฅผ ์ž…๋ ฅ)
    (info)ย 64bit ๋กœ ๋นŒ๋“œํ•  ๊ฒฝ์šฐ๋Š” VC-WIN32 ๋Œ€์‹  VC-WIN64Aย  ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

    32bit ๋กœ ๋นŒ๋“œ
    perl Configure VC-WIN32 no-idea no-md2 no-mdc2 no-rc5 no-rc4  no-asm --prefix=d:\devel\openssl\openssl-1.0.0d_vc2010
    • enable-static-engine ๋ฅผ Configure ์‹œ ์ž…๋ ฅํ•˜๋ฉด engine ์„ libeay32.dll ์— ํฌํ•จ์‹œํ‚ฌ์ˆ˜ ์žˆ๋‹ค.(๊ธฐ๋ณธ์€ ๋ณ„๋„์˜ dll)
    • Debugging symbol๋กœ ๋นŒ๋“œํ•˜๋ ค๋ฉด VC-WIN32 ๋Œ€์‹  debug-VC-WIN32 ๋ฅผ ์ž…๋ ฅํ•œ๋‹ค.
  • Makefile์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด ๋‹ค์Œ ๋ช…๋ น์–ด ์‹คํ–‰
    (info)ย 64bit ๋กœ ๋นŒ๋“œํ•  ๊ฒฝ์šฐ๋Š” ms\ย do_win64a ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.

    ms\do_ms.bat
  • nmake๋กœ ๋นŒ๋“œ ์‹œ์ž‘(static ์˜ ๊ฒฝ์šฐ ms\nt.mak ๋ฅผ ์‚ฌ์šฉ)

    nmake -f ms\ntdll.mak
  • test ๋ฅผ ์ˆ˜ํ–‰ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์–ด ์‹คํ–‰

    nmake -f ms\ntdll.mak test
  • prefix๋กœ ์ง€์ •ํ•ด์ค€ ๊ฒฝ๋กœ์— ์„ค์น˜ํ•˜๋ ค๋ฉด ๋‹ค์Œ ๋ช…๋ น์–ด ์‹คํ–‰

    nmake -f ms\ntdll.mak install

TroubleShooting

  • Windows์—์„œ ๋นŒ๋“œ์‹œ ๋‹ค์Œ ๊ฐ™์€ ์˜ค๋ฅ˜๊ฐ€ ๋‚˜๋ฉด ํ•ด๋‹น ์†Œ์Šค ํŒŒ์ผ์„ ์—๋””ํ„ฐ์—์„œ ์—ด์–ด์„œ UTF-8 ํ˜•์‹์œผ๋กœ ์ €์žฅํ•˜๊ฑฐ๋‚˜ ์†Œ์Šค์˜ ์ฒ˜์Œ ๋ถ€๋ถ„์— ''#pragma warning(disable: 4819)'' ๋ฅผ ์ถ”๊ฐ€ํ•ด ์ค€๋‹ค.

    ํ˜„์žฌ ์ฝ”๋“œ ํŽ˜์ด์ง€(number)์—์„œ ํ‘œ์‹œํ•  ์ˆ˜ ์—†๋Š” ๋ฌธ์ž๊ฐ€ ํŒŒ์ผ์— ๋“ค์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ฐ์ดํ„ฐ๊ฐ€ ์†์‹ค๋˜์ง€ ์•Š๊ฒŒ ํ•˜๋ ค๋ฉด ํ•ด๋‹น ํŒŒ์ผ์„ ์œ ๋‹ˆ์ฝ”๋“œ ํ˜•์‹์œผ๋กœ ์ €์žฅํ•˜์‹ญ์‹œ์˜ค.
    The file contains a character that cannot be represented in the current code page (number). Save the file in Unicode format to prevent data loss.

  • ์–ด์…ˆ๋ธ”๋Ÿฌ ์—๋Ÿฌ๊ฐ€ ๋‚˜๋ฉด config ์— no-asm ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

    md5-x86_64.s: Assembler messages:
    md5-x86_64.s:41: Error: 0xd76aa478 out range of signed 32bit displacement

Pre Compiled Binary

OpenSSL Wiki ์— Windows์šฉ ๋ฏธ๋ฆฌ ์ปดํŒŒ์ผ ํ•œ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๋‹ค์šด๋ฐ›์„ ์ˆ˜ ์žˆ๋Š” ์‚ฌ์ดํŠธ๊ฐ€ ์ •๋ฆฌ๋˜์–ด ์žˆ๋‹ค.


๊ฐ™์ด ๋ณด๊ธฐ