You are previewing Professional Node.js: Building Javascript Based Scalable Software.

Professional Node.js: Building Javascript Based Scalable Software

  1. Cover
  2. Contents
  3. Part I: Introduction and Setup
    1. Chapter 1: Installing Node
      1. Installing Node on Windows
      2. Installing on Mac OS X
      3. Installing Node Using the Source Code
      4. Setting Up and Using Node Package Manager
      5. Summary
    2. Chapter 2: Introducing Node
      1. Introducing the Event-Driven Programming Style
      2. How Node and JavaScript Make Writing Asynchronous Applications Easier
      3. Summary
  4. Part II: Node Core API Basics
    1. Chapter 3: Loading Modules
      1. Understanding How Node Loads Modules
      2. Exporting a Module
      3. Summary
    2. Chapter 4: Using Buffers to Manipulate, Encode, and Decode Binary Data
      1. Creating a Buffer
      2. Getting and Setting Bytes in a Buffer
      3. Slicing a Buffer
      4. Copying a Buffer
      5. Decoding a Buffer
      6. Summary
    3. Chapter 5: Using the Event Emitter Pattern to Simplify Event Binding
      1. Understanding the Standard Callback Pattern
      2. Understanding the Event Emitter Pattern
      3. Understanding Event Types
      4. Using the Event Emitter API
      5. Creating an Event Emitter
      6. Summary
    4. Chapter 6: Scheduling the Execution of Functions Using Timers
      1. Using setTimeout to Defer the Execution of a Function
      2. Using clearTimeout to Cancel the Execution of a Function
      3. Scheduling and Canceling the Repetitive Execution of a Function
      4. Using process.nextTick to Defer the Execution of a Function Until the Next Event Loop Iteration
      5. Blocking the Event Loop
      6. Escaping the Event Loop
      7. Using setTimeout Instead of setInterval to Force Serialization
      8. Summary
  5. Part III: Files, Processes, Streams, and Networking
    1. Chapter 7: Querying, Reading From, and Writing to Files
      1. Manipulating File Paths
      2. Introducing the fs Module
      3. Opening a File
      4. Reading from a File
      5. Summary
    2. Chapter 8: Creating and Controlling External Processes
      1. Executing External Commands
      2. Spawning Child Processes
      3. Signaling and Killing Processes
      4. Summary
    3. Chapter 9: Reading and Writing Streams of Data
      1. Using a Readable Stream
      2. Using Writable Streams
      3. Considering Some Stream Examples
      4. Avoiding the Slow Client Problem and Saving Your Server
      5. Summary
    4. Chapter 10: Building TCP Servers
      1. Creating a TCP Server
      2. Building a Simple TCP Chat Server
      3. Summary
    5. Chapter 11: Building HTTP Servers
      1. Understanding the http.ServerRequest Object
      2. Understanding the http.ServerResponse Object
      3. Streaming HTTP Chunked Responses
      4. Shutting Down the Server
      5. Example 1: Building a Server that Serves Static Files
      6. Example 2: Making Use of HTTP Chunked Responses and Timers
      7. Summary
    6. Chapter 12: Building a TCP Client
      1. Connecting to a Server
      2. Sending and Receiving Data
      3. Ending the Connection
      4. Handling Errors
      5. Building an Example Command-Line TCP Client
      6. Summary
    7. Chapter 13: Making HTTP Requests
      1. Making GET Requests
      2. Using Other HTTP Verbs
      3. Pooling Sockets Using http.Agent
      4. Using a Third-Party Request Module to Simplify HTTP Requests
      5. Summary
    8. Chapter 14: Using Datagrams (UDP)
      1. Understanding UDP
      2. Understanding the Uses of UDP
      3. Building a Datagram Server
      4. Creating a Simple Datagram Echo Server
      5. Building a Datagram Client
      6. Creating a Simple Datagram Command-Line Client
      7. Understanding and Using Datagram Multicast
      8. Summary
    9. Chapter 15: Securing Your TCP Server With TLS/SSL
      1. Understanding Private and Public Keys
      2. Building a TLS Server
      3. Building a TLS Client
      4. Building Some Examples
      5. Summary
    10. Chapter 16: Securing Your HTTP Server With HTTPS
      1. Building a Secure HTTP Server
      2. Creating an HTTPS Client
      3. Summary
  6. Part IV: Building and Debugging Modules and Applications
    1. Chapter 17: Testing Modules and Applications
      1. Using a Test Runner
      2. Using an Assertion Testing Module
      3. Testing Your Asynchronous Module
      4. Summary
    2. Chapter 18: Debugging Modules and Applications
      1. Using console.log
      2. Using Node’s Built-in Debugger
      3. Using Node Inspector
      4. Summary
    3. Chapter 19: Controlling the Callback Flow
      1. Understanding the Boomerang Effect
      2. Avoiding the Boomerang Effect by Declaring Functions
      3. Using the async Flow Control Library
      4. Summary
  7. Part V: Building Web Applications
    1. Chapter 20: Building and Using HTTP Middleware
      1. Understanding the Connect HTTP Middleware Framework
      2. Building Your Own HTTP Middleware
      3. Using the HTTP Middleware Bundled in Connect
      4. Summary
    2. Chapter 21: Making a Web Application Using Express.js
      1. Initializing Your Express.js Application
      2. Setting Up Middleware in Your Application
      3. Routing Requests
      4. Summary
    3. Chapter 22: Making Universal Real-Time Web Applications Using Socket.io
      1. Understanding How WebSockets Work
      2. Using Socket.IO to Build WebSocket Applications
      3. Summary
  8. Part VI: Connecting to Databases
    1. Chapter 23: Connecting to MYSQL Using node-mysql
      1. Using a Library to Connect to and Communicate with a MySQL Database
      2. Adding Data to the Database with Security Concerns in Mind
      3. Reading Data Efficiently
      4. Summary
    2. Chapter 24: Connecting to CouchDB Using Nano
      1. Installing Nano
      2. Connecting and Creating a Database
      3. Storing Documents
      4. Creating and Using CouchDB Views
      5. Attaching Files to a CouchDB Document
      6. Summary
    3. Chapter 25: Connecting to MongoDB Using MongooSE
      1. Installing Mongoose
      2. Understanding How Mongoose Uses Models to Encapsulate Database Access
      3. Connecting to MongoDB
      4. Defining a Schema
      5. Defining a Model
      6. Summary
  9. Introduction
  10. Advertisements
O'Reilly logo

Chapter 15

Securing Your TCP Server with TLS/SSL

WHAT’S IN THIS CHAPTER?

  • Understanding how the Public Key Infrastructure works
  • Creating a TLS server
  • Connecting to a TLS server
  • Validating the server and client certificates
  • Receiving and sending data securely

TLS (Transport Layer Security) and SSL (Secure Socket Layer) allow client/server applications to communicate across a network in a way designed to prevent eavesdropping (others looking into your messages) and tampering (others changing your message). TLS/SSL encrypts the segments of network connections above the transport layer, enabling both privacy and message authentication.

TLS is based on earlier SSL specifications developed by Netscape. In fact, TLS 1.0 is also known as SSL 3.1, and the latest version (TLS 1.2) is also known as SSL 3.3. This chapter uses TLS instead of the deprecated SSL nomenclature.

UNDERSTANDING PRIVATE AND PUBLIC KEYS

Public key cryptography refers to a cryptographic system that requires two separate keys. One key is used to encrypt the plaintext, and the other key is used to decrypt the encrypted message. One of these keys is public, and the other is private. If the plaintext is encrypted using the public key, only the private key can unlock it, enabling private communication from the public to the private key owner. If the plaintext is encrypted using the private key, the public key can decrypt it. In this case the system verifies the signatures of the documents signed by the owner of the private ...

The best content for your career. Discover unlimited learning on demand for around $1/day.