net.i2p.util

## Class SSLEepGet

- java.lang.Object
- - net.i2p.util.EepGet
  - - net.i2p.util.SSLEepGet

-     public class SSLEepGet
      extends EepGet

  HTTPS only, no retries, no min and max size options, no timeout option As of 0.9.45, supports redirect to https (redirect to http will still fail). Fails on bad certs (must have a valid cert chain) Self-signed certs or CAs not in the JVM key store must be loaded to be trusted. Since 0.8.2, loads additional trusted CA certs from $I2P/certificates/ssl/ and ~/.i2p/certificates/ssl/ Since 0.9.33, HTTP proxies (CONNECT) supported. Proxy auth not supported.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `SSLEepGet.ProxyType` Not all may be supported.
    `static class` | `SSLEepGet.SSLState` An opaque class for the caller to pass to repeated instantiations of SSLEepGet.

    - ### Nested classes/interfaces inherited from class net.i2p.util.EepGet

      `EepGet.AUTH_MODE, EepGet.AuthState, EepGet.CLIStatusListener, EepGet.Gunzipper, EepGet.StatusListener`

  - ### Field Summary

    - ### Fields inherited from class net.i2p.util.EepGet

      `_aborted, _acceptRanges, _actualURL, _alreadyTransferred, _authState, _bytesRemaining, _bytesTransferred, _cacheControl, _contentEncoding, _contentLanguage, _contentType, _context, _cookie, _csp, _currentAttempt, _decompressException, _encodingChunked, _etag, _etagOrig, _expiryDate, _extraHeaders, _fetchHeaderTimeout, _fetchInactivityTimeout, _fetchTotalTimeout, _isGzippedResponse, _keepFetching, _lastModified, _lastModifiedOrig, _listeners, _log, _notModified, _numRetries, _out, _outputFile, _outputStream, _proxy, _proxyHost, _proxyIn, _proxyOut, _proxyPort, _redirectLocation, _redirects, _referrerPolicy, _responseCode, _responseText, _server, _shouldProxy, _shouldWriteErrorToOutput, _status, _transferEncoding, _transferFailed, _url, _vary, _xContentTypeOptions, _xframeOptions, _xPoweredBy, _xssProtection, CONNECT_TIMEOUT, INACTIVITY_TIMEOUT, MAX_COMPLETE_FAILS, USER_AGENT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SSLEepGet(I2PAppContext ctx, OutputStream outputStream, String url)` A new SSLEepGet with a new SSLState
    `SSLEepGet(I2PAppContext ctx, OutputStream outputStream, String url, long maxSize, SSLEepGet.SSLState state)`
    `SSLEepGet(I2PAppContext ctx, OutputStream outputStream, String url, SSLEepGet.SSLState state)`
    `SSLEepGet(I2PAppContext ctx, SSLEepGet.ProxyType type, String proxyHost, int proxyPort, OutputStream outputStream, String url)` Use a proxy.
    `SSLEepGet(I2PAppContext ctx, SSLEepGet.ProxyType type, String proxyHost, int proxyPort, OutputStream outputStream, String url, SSLEepGet.SSLState state)` Use a proxy.
    `SSLEepGet(I2PAppContext ctx, SSLEepGet.ProxyType type, String proxyHost, int proxyPort, String outputFile, String url)` Use a proxy.
    `SSLEepGet(I2PAppContext ctx, SSLEepGet.ProxyType type, String proxyHost, int proxyPort, String outputFile, String url, SSLEepGet.SSLState state)` Use a proxy.
    `SSLEepGet(I2PAppContext ctx, String outputFile, String url)` A new SSLEepGet with a new SSLState
    `SSLEepGet(I2PAppContext ctx, String outputFile, String url, SSLEepGet.SSLState state)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doFetch(SocketTimeout timeout)` This reads the response to a single fetch.
    `void` | `forceDNSOverHTTPS(boolean on)` Override the config setting, force DNSoverHTTPS on or off Call before the fetch.
    `void` | `forceDNSOverHTTPS(boolean on, boolean forceIPv6)` Override the config setting, force DNSoverHTTPS on or off Call before the fetch.
    `SSLEepGet.SSLState` | `getSSLState()` Pass this back to the next SSLEepGet constructor for faster fetches.
    `static void` | `main(String[] args)` SSLEepGet https://foo/bar or to save cert chain: SSLEepGet -s https://foo/bar
    `protected void` | `sendRequest(SocketTimeout timeout)`

    - ### Methods inherited from class net.i2p.util.EepGet

      `addAuthorization, addHeader, addStatusListener, fetch, fetch, fetch, getAcceptRanges, getCacheControl, getContentEncoding, getContentLanguage, getContentType, getCookie, getCSP, getEtag, getExpiryDate, getLastModified, getNotModified, getReferrerPolicy, getRequest, getServer, getStatus, getStatusCode, getStatusText, getTransferEncoding, getVary, getXContentTypeOptions, getXframeOptions, getXPoweredBy, getXSSProtection, parseAuthArgs, readChunkLength, readHeaders, setPostData, setPostData, setPostData, setWriteErrorToOutput, shouldReadBody, stopFetching, suggestName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           OutputStream outputStream,
                           String url)

      A new SSLEepGet with a new SSLState

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           OutputStream outputStream,
                           String url,
                           long maxSize,
                           SSLEepGet.SSLState state)

      Parameters:
        `maxSize` - The maximum size of the response
        `state` - an SSLState retrieved from a previous SSLEepGet with getSSLState(), or null. This makes repeated fetches from the same host MUCH faster, and prevents repeated key store loads even for different hosts.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           OutputStream outputStream,
                           String url,
                           SSLEepGet.SSLState state)

      Parameters:
        `state` - an SSLState retrieved from a previous SSLEepGet with getSSLState(), or null. This makes repeated fetches from the same host MUCH faster, and prevents repeated key store loads even for different hosts.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           SSLEepGet.ProxyType type,
                           String proxyHost,
                           int proxyPort,
                           OutputStream outputStream,
                           String url)

      Use a proxy.
      Parameters:
        `proxyHost` - Must be valid hostname or literal IPv4/v6. If type is INTERNAL, set to "localhost".
        `proxyPort` - Must be valid, -1 disallowed, no default. If type is INTERNAL, set to 4444.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           SSLEepGet.ProxyType type,
                           String proxyHost,
                           int proxyPort,
                           OutputStream outputStream,
                           String url,
                           SSLEepGet.SSLState state)

      Use a proxy.
      Parameters:
        `proxyHost` - Must be valid hostname or literal IPv4/v6. If type is INTERNAL, set to "localhost".
        `proxyPort` - Must be valid, -1 disallowed, no default. If type is INTERNAL, set to 4444.
        `state` - an SSLState retrieved from a previous SSLEepGet with getSSLState(), or null. This makes repeated fetches from the same host MUCH faster, and prevents repeated key store loads even for different hosts.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           SSLEepGet.ProxyType type,
                           String proxyHost,
                           int proxyPort,
                           String outputFile,
                           String url)

      Use a proxy.
      Parameters:
        `proxyHost` - Must be valid hostname or literal IPv4/v6. If type is INTERNAL, set to "localhost".
        `proxyPort` - Must be valid, -1 disallowed, no default. If type is INTERNAL, set to 4444.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           SSLEepGet.ProxyType type,
                           String proxyHost,
                           int proxyPort,
                           String outputFile,
                           String url,
                           SSLEepGet.SSLState state)

      Use a proxy.
      Parameters:
        `proxyHost` - Must be valid hostname or literal IPv4/v6. If type is INTERNAL, set to "localhost".
        `proxyPort` - Must be valid, -1 disallowed, no default. If type is INTERNAL, set to 4444.
        `state` - an SSLState retrieved from a previous SSLEepGet with getSSLState(), or null. This makes repeated fetches from the same host MUCH faster, and prevents repeated key store loads even for different hosts.

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           String outputFile,
                           String url)

      A new SSLEepGet with a new SSLState

    - #### SSLEepGet

          public SSLEepGet(I2PAppContext ctx,
                           String outputFile,
                           String url,
                           SSLEepGet.SSLState state)

      Parameters:
        `state` - an SSLState retrieved from a previous SSLEepGet with getSSLState(), or null. This makes repeated fetches from the same host MUCH faster, and prevents repeated key store loads even for different hosts.

  - ### Method Detail

    - #### doFetch

          protected void doFetch(SocketTimeout timeout)
                          throws IOException

      Description copied from class: `EepGet`
      This reads the response to a single fetch. Call after sendRequest()
      Overrides:
        `doFetch` in class `EepGet`
      Parameters:
        `timeout` - may be null
      Throws:
        `IOException`

    - #### forceDNSOverHTTPS

          public void forceDNSOverHTTPS(boolean on)

      Override the config setting, force DNSoverHTTPS on or off Call before the fetch.

    - #### forceDNSOverHTTPS

          public void forceDNSOverHTTPS(boolean on,
                                        boolean forceIPv6)

      Override the config setting, force DNSoverHTTPS on or off Call before the fetch.
      Parameters:
        `forceIPv6` - use IPv6 for BOTH the connection to the DoH server AND for the queried address. on must be true.

    - #### getSSLState

          public SSLEepGet.SSLState getSSLState()

      Pass this back to the next SSLEepGet constructor for faster fetches. This may be called either after the constructor or after the fetch.

    - #### main

          public static void main(String[] args)

      SSLEepGet https://foo/bar or to save cert chain: SSLEepGet -s https://foo/bar

    - #### sendRequest

          protected void sendRequest(SocketTimeout timeout)
                              throws IOException

      Overrides:
        `sendRequest` in class `EepGet`
      Parameters:
        `timeout` - may be null
      Throws:
        `IOException`