TLS Handshake and Certificate Errors: System Time, Certificate Validity, and SNI

Narrow down TLS and certificate errors by checking time sync, certificate validity, hostname matching, and SNI settings—and learn why disabling certificate verification is not a reliable everyday fix.

At a glance

Useful for TLS handshake errors, expired certificates, hostname mismatches, and unknown authority messages in v2rayN or Xray logs: verify Windows time first, then check certificate validity and the hostname being accessed, followed by SNI, subscription fields, and server settings. Avoid masking the real issue by disabling verification.

Which layer is failing during TLS

The TLS handshake takes place while the proxy core establishes an encrypted connection to the remote server. v2rayN imports subscriptions, edits servers, and generates configuration; the Xray core handles the actual connection, while the system proxy or TUN determines which application traffic enters the client. These layers must be assessed separately: if a browser is not using the proxy, even a correct node configuration will never reach the core. If the application is connected but the core cannot complete the TLS handshake, certificate or handshake errors appear in the log.

VMess and VLESS are proxy protocol names, while TLS is the transport security layer. Using VLESS does not necessarily mean TLS is enabled, and using VMess does not imply a different certificate verification method. Check the security type, destination port, server address, SNI, and hostname covered by the certificate in the node's transport settings. Port 443 is common for TLS, but it is not mandatory; if the server uses another port, the client must match it.

Application connectedCore dials outSends SNIReceives certificateVerifies certificateConnection established
443
Common TLS server ports
TLS 1.2
Common protocol versions
TLS 1.3
Common protocol versions
2 dates
notBefore and notAfter

When troubleshooting, find the first TLS error rather than focusing only on later connection closures, EOF messages, or retry failures. After certificate verification fails, the core usually ends the current connection; subsequent read failures are only consequences. If every node in the same subscription fails at once, check local time, network middleboxes, and client-wide settings first. If only one hostname fails, the issue is more likely that node's certificate, SNI, or server deployment.

Step 1: Check Windows time, time zone, and synchronization status

A certificate contains a start time, notBefore, and an expiration time, notAfter. The core uses the local system clock to determine whether the certificate is currently valid, so an incorrect date, time zone, or clock offset can trigger “not yet valid” or “has expired” errors. For example, a computer may physically be in UTC+8 while its time zone is set to UTC and its clock has been manually adjusted to local time. The displayed time may look close to correct, while the underlying time reference is still offset.

Open Windows Settings → Time & language → Date & time. Confirm that “Set time automatically” and “Set time zone automatically” match the current environment, then select Sync now. Corporate networks and managed devices may use an internal time source. Do not replace that policy casually; record the synchronization source and offset, then ask the device administrator to verify them.

  1. Compare the system date, hour, and minute—not just the minute shown in the taskbar.
  2. Confirm that the time zone name matches your location; in regions using daylight saving time, also check the current offset.
  3. Query the status to see the most recent successful synchronization time and time source.
  4. After correcting the clock, fully exit v2rayN, restart the core, and retest the same node.
w32tm /query /status
tzutil /g
powershell -NoProfile -Command "Get-Date -Format o"

Use 60 seconds as a practical troubleshooting threshold, not as a universal tolerance defined by certificate standards: if the local clock differs from a trusted time source by more than 60 seconds, correct it first. TLS implementations and server deployments may behave differently, so do not rely on a grace period that may exist in one implementation. If every node recovers after the clock is corrected, the problem is in the local time chain; there is no need to edit subscription nodes one by one.

Step 2: Check certificate validity, the chain, and the hostname

Once the time is correct, inspect the certificate itself. At minimum, check its validity period, Subject Alternative Name entries, and whether the issuing chain reaches a root certificate trusted by the system. Checking only the expiration date shown in a UI is not enough: the certificate may not have become valid yet, or an intermediate certificate may be missing. If a server replacement updates only the leaf certificate without supplying the correct intermediate certificate, it may work in some environments while others report an unknown issuer.

Hostname matching is based primarily on the certificate's Subject Alternative Name. If the client connects by IP while the certificate covers only a hostname, direct IP validation will usually fail. Likewise, if the connection uses one hostname but SNI names another hostname not covered by the certificate, the result is a name mismatch. Wildcard certificates also have limited scope: *.example.com generally covers one subdomain level, but does not automatically cover deeper levels or the root domain.

Check Value to verify What to do if it fails
Valid from Current time is not earlier than notBefore Calibrate the local clock, or redeploy a certificate that is already valid on the server
Expires Current time is earlier than notAfter Renew it on the server and confirm that the new certificate is loaded
Hostname coverage The actual SNI appears in the certificate name list Correct the SNI, or issue a certificate for the actual hostname
Certificate chain The leaf certificate, intermediate certificates, and trusted root form a valid chain Add the missing intermediate certificate and check the system trust store and network interception

Conclusion: handle single-node and all-node failures separately

If only one server name fails, check that node's certificate and SNI first. If multiple nodes with different hostnames simultaneously report an unknown issuer or time error, check the system clock, system trust store, and TLS inspection devices on the network.

Also distinguish an expired certificate from an old connection that is still working. An established long-lived connection may not drop the moment a certificate expires, but a new connection will perform a fresh handshake and validation. This can make a newly started client fail while an existing connection remains temporarily usable, or reveal the problem only after switching networks. Fully restart the core and establish a new connection when testing; do not rely on a single session that is still open.

Step 3: Check SNI, the server address, and subscription fields

SNI is the server name sent by the client during the TLS handshake, allowing the server to select a certificate and virtual host. It is not the same as the DNS result: the server address determines which IP to connect to, while SNI declares the hostname requested during the handshake. They can differ in certain deployments, but the server must support that arrangement, and the returned certificate must cover the hostname used for verification.

In v2rayN, select the target server and use the context menu's “Edit server” option to check the address, port, transport security, and SNI. To inspect global behavior, open Settings → Parameters. Field groupings may vary between interface versions, but do not mechanically copy “address,” “Host,” and “SNI” as if they were the same value. A WebSocket Host is an HTTP request header, while SNI belongs to the TLS handshake. A reverse proxy may require them to match—or explicitly require them to differ.

{
  "streamSettings": {
    "security": "tls",
    "tlsSettings": {
      "serverName": "edge.example.com",
      "allowInsecure": false
    }
  }
}

Error: x509: certificate is valid for ..., not ...

Cause and fix: The name being verified is outside the certificate's coverage—check the server address and SNI, use the correct hostname included in the certificate, or redeploy a matching certificate on the server.

Error: remote error: tls: handshake failure

Cause and fix: The server rejected the connection during the handshake—check the virtual host associated with the SNI, TLS version, port, and server listener. Do not simply keep switching the system proxy on the client.

If the node came from a subscription, record the original values first, then update the subscription once and compare the fields. If a manual correction works only briefly and fails again after the next update, the subscription source is still delivering an incorrect value. Fix the subscription generator instead of editing every imported node again. If several nodes use the same hostname, check their ports and transport settings individually; identical names do not prove that their server entry points are identical.

Step 4: Narrow the issue down from the exact error text

TLS log messages vary with the core version and error path, but the key information usually falls into four groups: time, hostname, trust chain, and handshake negotiation. When sharing logs, keep the connection target and timestamps around the error, but do not expose UUIDs, subscription URLs, or full configuration. Focus on where the first failure occurred, not on the number of retry records that followed.

Error: x509: certificate has expired or is not yet valid

Cause and fix: The local clock is outside the certificate's validity period, or the server certificate has actually expired—sync Windows time first, then check notBefore and notAfter.

Error: x509: certificate signed by unknown authority

Cause and fix: The certificate chain does not reach a trusted root—check whether the server sends the complete intermediate chain, and confirm whether the system trust store or a network inspection device has altered the certificate.

Error: tls: failed to verify certificate

Cause and fix: Certificate verification failed—continue reading the specific x509 reason in the same log entry and address the time, hostname, or issuing chain. Do not draw a conclusion from this generic layer alone.

Error: unexpected EOF

Cause and fix: The peer or an intermediate network device closed the connection during the handshake—first check for a preceding certificate error, then verify the port, SNI, server listener, and network interception.

If the log shows only a timeout and no certificate details, the connection may not have reached certificate verification. Confirm DNS resolution, the destination IP, the TCP port, and network reachability first. Connecting to the wrong port—for example, treating a plain HTTP port as a TLS endpoint—can also result in a closed connection or an unrecognized handshake error. An open port only proves that a process is listening; it does not prove that the listener is the expected TLS service.

If a company, campus, or managed network deploys TLS inspection, the certificate issuer seen by the client may differ from the one seen on a direct connection. With authorization, switch to another compliant network for comparison: if the same device and node behave differently after only the network changes, continue investigating the intermediate network. If the same hostname or validity error appears on the other network, the node configuration or server certificate is more likely at fault.

Why certificate verification should not be disabled long term

“Skip certificate verification” usually tells the client to stop checking the certificate name and trust chain. It does not fix an expired certificate, incorrect SNI, wrong port, or server virtual host. The option may keep the connection appearing to work, but it removes an important step for confirming the remote identity, making bad configuration and certificate replacement by a network middlebox harder to detect. At most, use it briefly for comparison in a controlled environment; it should not be the conclusion of routine configuration.

A more effective comparison changes one condition at a time. Keep the server address, port, and network unchanged while correcting only the system time. Once the time is confirmed, correct only the SNI, then verify the server certificate chain. Restart the core and create a new connection after each step, recording whether the error changes from “not yet valid” to “name mismatch,” or progresses to a later protocol stage. The change in error is itself a troubleshooting clue.

  1. Restore allowInsecure: false so the test includes full certificate verification.
  2. Confirm the system date, time zone, and synchronization source, then fully restart v2rayN.
  3. Check notBefore, notAfter, and the certificate hostname list.
  4. Check the server address, port, SNI, Host, and the original subscription fields.
  5. Check the server virtual host, certificate chain, and actual listening endpoint.
  6. Only then compare different networks to determine whether an intermediate device is involved.

Conclusion: use successful full verification as the fix standard

The corrected configuration should establish a new connection with certificate verification enabled and remain correct after a subscription update. If it connects only when verification is disabled, the root cause has not been fixed.

Finish with a fixed decision path: if every node fails, check time and network first; if one hostname fails, check its certificate and SNI; for a name error, verify the field mapping; for an unknown issuer, inspect the certificate chain; for a timeout alone, return to DNS, the port, and the listener. This avoids trial and error across system proxy settings, routing rules, and TLS parameters, while clarifying whether the issue belongs to client configuration, proxy-core logs, subscription data, or server deployment.

Download client