2ndQuadrant is now part of EDB

Bringing together some of the world's top PostgreSQL experts.

2ndQuadrant | PostgreSQL
Mission Critical Databases
  • Contact us
  • EN
    • FR
    • IT
    • ES
    • DE
    • PT
  • Support & Services
  • Products
  • Downloads
    • Installers
      • Postgres Installer
      • 2UDA – Unified Data Analytics
    • Whitepapers
      • Business Case for PostgreSQL Support
      • Security Best Practices for PostgreSQL
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
  • Postgres Learning Center
    • Webinars
      • Upcoming Webinars
      • Webinar Library
    • Whitepapers
      • Business Case for PostgreSQL Support
      • Security Best Practices for PostgreSQL
    • Blog
    • Training
      • Course Catalogue
    • Case Studies
      • Performance Tuning
        • BenchPrep
        • tastyworks
      • Distributed Clusters
        • ClickUp
        • European Space Agency (ESA)
        • Telefónica del Sur
        • Animal Logic
      • Database Administration
        • Agilis Systems
      • Professional Training
        • Met Office
        • London & Partners
      • Database Upgrades
        • Alfred Wegener Institute (AWI)
      • Database Migration
        • International Game Technology (IGT)
        • Healthcare Software Solutions (HSS)
        • Navionics
    • Books
      • PostgreSQL 11 Administration Cookbook
      • PostgreSQL 10 Administration Cookbook
      • PostgreSQL High Availability Cookbook – 2nd Edition
      • PostgreSQL 9 Administration Cookbook – 3rd Edition
      • PostgreSQL Server Programming Cookbook – 2nd Edition
      • PostgreSQL 9 Cookbook – Chinese Edition
    • Videos
    • Events
    • PostgreSQL
      • PostgreSQL – History
      • Who uses PostgreSQL?
      • PostgreSQL FAQ
      • PostgreSQL vs MySQL
      • The Business Case for PostgreSQL
      • Security Information
      • Documentation
  • About Us
    • About 2ndQuadrant
    • 2ndQuadrant’s Passion for PostgreSQL
    • News
    • Careers
    • Team Profile
  • Blog
  • Menu Menu
You are here: Home1 / Blog2 / Andrew's PlanetPostgreSQL3 / NSS on Windows for PostgreSQL development
NSS on Windows for PostgreSQL development
Andrew Dunstan

NSS on Windows for PostgreSQL development

August 5, 2020/0 Comments/in Andrew's PlanetPostgreSQL /by Andrew Dunstan

Daniel Gustafsson has done some terrific work on using NSS as an alternative TLS library to OpenSSL for PostgreSQL. I’ve done some work making that build and run on Windows. Daniel recently asked how to get a working NSS on Windows to use for development, and this blog is about that process.

First you need to start with a clean Windows environment. The simplest way is a new virtual machine. Microsoft provides time limited images that can be used with VirtualBox, or you can use a cloud provider. In my case I used a machine running on Amazon EC2.

We’re going to use the chocolatey package manager. This greatly simplifies installing a lot of things on Windows. Connect to the windows instance, start cmd.exe as Administrator, and run

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[System.Net.ServicePointManager]::SecurityProtocol = 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

Once that’s done, we’re going to install a few utilities and Microsoft Visual Studio

choco install -y wget git hg
choco install -y visualstudio2019community

Visual Studio takes a while to install. When it’s done, open the Visual Studio Installer from the Start menu, and modify the installation by adding the ‘Desktop Development for C++’ and ‘Game development for C++’ components and clicking the ‘Modify’ button.

That also takes a while, so while we’re waiting, back in in our command prompt we can add the rest of what we’re going to need.

We’re going to install Mozilla’s build environment, and the gyp build tool, and get the code for NSS and NSPR which it depends on. We’ll do all this in a directory created to contain all our work. First, we’ll need to refresh our environment so the shell knows about the stuff we just installed.

refreshenv

mkdir \build
cd \build

wget https://ftp.mozilla.org/pub/mozilla.org/mozilla/libraries/win32/MozillaBuildSetup-Latest.exe
.\MozillaBuildSetup-Latest.exe /S

git clone https://chromium.googlesource.com/external/gyp
hg clone https://hg.mozilla.org/projects/nspr
hg clone https://hg.mozilla.org/projects/nss

At this stage, when everything is done it’s best to restart the machine as one of the dependent components we installed needs it.

When the machine is restarted, connect again, and this time start an ‘x64 Native Tools Command Prompt for VS 2019’. We need this so our environment is all set up nicely to use the Microsoft tools.

In that window we need to add a few things to the PATH and then start the Mozilla build environment:

set path=%path%;C:\mozilla-build\python;c:\mozilla-build\bin;c:\build\gyp
set path=%path%;%ProgramFiles(x86)%\Microsoft Visual Studio\Installer
cd \mozilla-build\msys
msys

This starts a new window. In that window we navigate to our build directory and run the NSS build script:

cd /c/build
nss/build.sh

That should result in output that looks like this (I’m eliding quite a lot of it):

$ nss/build.sh
NSPR [1/5] configure ...
NSPR [2/5] make ...
NSPR [3/5] NOT building tests
NSPR [4/5] NOT running tests
NSPR [5/5] install ...
ninja: Entering directory `c:/build/nss/out/Debug'
....
[806/1222] LINK_EMBED(DLL) c:/build/dist/Debug/lib\nssckbi-testlib.dll
nssckbi-testlib.dll.exp : warning LNK4070: /OUT:nssckbi.dll directive in .EXP differs from output filename 'c:\build\dist\Debug\lib\nssckbi-testlib.dll'; ignoring directive
[1222/1222] STAMP obj\nss_tests.actions_depends.stamp

You now have a Debug version of NSS in \build\dist\Debug The NSS headers are in \build\dist\public and the NSPR headers are in \build\dist\Debug\include.

In case you don’t feel like going to all this trouble but want to play along, I’ve stashed a copy of my latest build on GitHub

In a later blog I’ll show how to use what’s built here with PostgreSQL and the patch that Daniel has done (with some additions from me).

Share this entry
  • Share on Facebook
  • Share on Twitter
  • Share on WhatsApp
  • Share on LinkedIn
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Get in touch with us!

Recent Posts

  • Random Data December 3, 2020
  • Webinar: COMMIT Without Fear – The Beauty of CAMO [Follow Up] November 13, 2020
  • Full-text search since PostgreSQL 8.3 November 5, 2020
  • Random numbers November 3, 2020
  • Webinar: Best Practices for Bulk Data Loading in PostgreSQL [Follow Up] November 2, 2020

Featured External Blogs

Tomas Vondra's Blog

Our Bloggers

  • Simon Riggs
  • Alvaro Herrera
  • Andrew Dunstan
  • Craig Ringer
  • Francesco Canovai
  • Gabriele Bartolini
  • Giulio Calacoci
  • Ian Barwick
  • Marco Nenciarini
  • Mark Wong
  • Pavan Deolasee
  • Petr Jelinek
  • Shaun Thomas
  • Tomas Vondra
  • Umair Shahid

PostgreSQL Cloud

2QLovesPG 2UDA 9.6 backup Barman BDR Business Continuity community conference database DBA development devops disaster recovery greenplum Hot Standby JSON JSONB logical replication monitoring OmniDB open source Orange performance PG12 pgbarman pglogical PG Phriday postgres Postgres-BDR postgres-xl PostgreSQL PostgreSQL 9.6 PostgreSQL10 PostgreSQL11 PostgreSQL 11 PostgreSQL 11 New Features postgresql repmgr Recovery replication security sql wal webinar webinars

Support & Services

24/7 Production Support

Developer Support

Remote DBA for PostgreSQL

PostgreSQL Database Monitoring

PostgreSQL Health Check

PostgreSQL Performance Tuning

Database Security Audit

Upgrade PostgreSQL

PostgreSQL Migration Assessment

Migrate from Oracle to PostgreSQL

Products

HA Postgres Clusters

Postgres-BDR®

2ndQPostgres

pglogical

repmgr

Barman

Postgres Cloud Manager

SQL Firewall

Postgres-XL

OmniDB

Postgres Installer

2UDA

Postgres Learning Center

Introducing Postgres

Blog

Webinars

Books

Videos

Training

Case Studies

Events

About Us

About 2ndQuadrant

What does 2ndQuadrant Mean?

News

Careers 

Team Profile

© 2ndQuadrant Ltd. All rights reserved. | Privacy Policy
  • Twitter
  • LinkedIn
  • Facebook
  • Youtube
  • Mail
PostgreSQL 13: Don’t let slots kill your primary PostgreSQL 13: Don’t let slots kill your primary Webinar: Being Committed – A Review of Transaction Control Statements...
Scroll to top
×