Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?


Example: Configuring the PKI in Junos OS

This example shows how to configure, verify, and troubleshoot the PKI. This topic includes the following sections:


This example uses the following hardware and software components:

  • Junos OS Release 9.4 or later

  • Junos OS with Enhanced Services Release 8.5 through 9.3

  • SRX Series devices or J Series devices


This configuration example has been tested using the software release listed and is assumed to work on all later releases.

Network Topology

Figure 1 shows the network topology used for this example to configure a policy-based VPN.

Figure 1: Network Topology DiagramNetwork Topology Diagram

Required Settings


The PKI administration is the same for both policy-based VPNs and route-based VPNs.

This example assumes the following settings:

  • The remote VPN peer is a Juniper Networks SSG5 Firewall/VPN device (most commonly used for branch offices).

  • The internal LAN interface of the device is ge-0/0/0 in zone trust and has a private IP subnet.

  • The Internet interface of the device is ge-0/0/3 in zone untrust and has a public IP.

  • All traffic between the local and remote LANs is permitted, and traffic can be initiated from either side.

  • The SSG5 has been pre-configured correctly and loaded with a ready-to-use local certificate, CA-certificate, and CRL.

  • The SSG5 device is configured to use the FQDN of (IKE ID).

  • PKI certificates with 1024–bit keys are used for the IKE negotiations on both sides.

  • The CA is a standalone CA at the domain for both VPN peers.


For more information about the procedures for PKI administration and usage in Junos OS, see the Junos OS Security Configuration Guide.


For more information on using a CA from PKI vendors such as Microsoft and OpenSSL, see Appendix B: Administering Common Certificate Authorities.


More information about PKI configuration with SSG5 and other Juniper Networks ScreenOS-based platforms. see the Juniper Networks PKI (Public Key Infrastructure) Primer & FAQ, Using X.509 Certificates in ScreenOS.


This topic includes the following section:

Basic Configuration Steps for PKI

Step-by-Step Procedure

  1. Configure an IP address and protocol family on the Gigabit Ethernet interfaces (ge-0/0/0.0 and ge-0/0/3.0):

  2. Configure a default route to the Internet nexthop:

    In this example, the VPN traffic is incoming on interface ge-0/0/0.0 with the nexthop of Thus the traffic is outgoing on the interface ge-0/0/3.0. Any tunnel policy must consider incoming and outgoing interfaces.


    Optionally you can use a dynamic routing protocol such as OSPF (not described in this document). When processing the first packet of a new session, the Junos OS device first performs a route lookup. The static route, which is also the default route, dictates the zone for the outgoing VPN traffic.

  3. Set the system time and date.

    After the configuration is committed, verify the clock settings using the show system uptime command.

  4. Set the NTP server address.

  5. Set the Domain Name System (DNS) configuration.

    Many CAs use hostnames (for example, FQDN) to specify various elements of the PKI. Since the CDP is usually specified using a URL containing an FQDN, you must configure a DNS resolver on the Junos OS device.

  6. Generate the certificate request by:

    • Creating a CA profile to specify the CA settings.

    • Generating the PKCS10 certificate request.

      The PKCS10 certificate request process involves generating a public/private key pair and then generating the certificate request itself, using the key pair.


      Take note of the following information about the CA profile:

      • The CA profile defines the attributes of a certificate authority.

      • Each CA profile is associated with a CA certificate. If a new or renewed CA certificate needs to be loaded without removing the older CA certificate, a new profile must be created. This profile can also be used for online fetching of the CRL.

      • There can be multiple such profiles present in the system created for different users.

    Step-by-Step Procedure
    1. Create a trusted CA profile with the following mandatory values:

      • CA profile name — (ms-ca for this example) (any value)

      • CA identity— (CA domain name)

    2. Create a revocation check to specify a method for checking certificate revocation:


      You can use the option disable to disable the revocation check or select crl to configure the CRL attributes.

    3. Set the refresh interval, in hours, to specify the frequency to update the CRL. The default values are: next-update time in CRL, or 1 week if no next-update time is specified.

    4. Specify the location (URL) to retrieve the CRL (HTTP or LDAP). By default, the URL is empty and uses CDP information embedded in the CA certificate.


      The URL can include the server-name/port information such as, ldap://<ip-or-fqdn>:<port>). If the port number is missing, HTTP will use port 80, or LDAP will use port 443. Currently you can configure only one URL. Support for backup URL configuration is not available.

    5. Specify an e-mail address to send the certificate request directly to a CA administrator.


      If you specify a CA administrator e-mail address to send the certificate request to, then the system composes an e-mail from the certificate request file and forwards it to the specified e-mail address. The e-mail status notification is sent to the administrator.


      The certificate request can be sent to the CA through an out-of-band method.

    6. Commit the configuration:

    7. Generate a key-pair request.

      When the CA profile is configured, the next step is to generate a key pair on the Junos OS device. To generate the private and public key pair:

      The PKCS10 certificate request is generated and stored on the system as a pending certificate or certificate request. An e-mail notification will be sent to the administrator of the CA (in this example,


      Currently the Junos OS supports only the RSA algorithm and does not support the Digital Signature Algorithm (DSA). A unique identity called certificate-ID is used to name the generated key pair. This ID is also used in certificate enrollment and request commands to get the right key pair. The generated key pair is saved in the certificate store in a file with the same name as the certificate-ID. The file size can be 512, 1024, or 2048 bits.


      A default (fallback) profile can be created if intermediate CAs are not preinstalled in the device. The default profile values are used in the absence of a specifically configured CA profile.

      In the case of a CDP, the following order is followed:

      • Per CA profile

      • CDP embedded in CA certificate

      • Default CA profile

      We recommend using a specific CA profile instead of a default profile.

  7. Generate a local digital certificate request in the PKCS-10 format.


    In the sample of the PKCS10 certificate, the request starts with and includes the “BEGIN CERTIFICATE REQUEST” line and ends with and includes the “END CERTIFICATE REQUEST” line. This portion can be copied and pasted to your CA for enrollment. Optionally, you can also offload the “ms-cert-req” file and send that to your CA.

    Generate the PKCS10 certificate request to be sent to the CA.

    The available options are:

    • certificate-id — Name of the local digital certificate and the public/private key pair. This ensures that the proper key pair is used for the certificate request and ultimately for the local certificate.

    • subject — Distinguished name format that contains the common name, department, company name, state, and country:

      • CN — Common name

      • OU — Department

      • O — Company name

      • L — Locality

      • ST — State

      • C — Country

      • CN — Phone

      • DC — Domain component


        You are not required to enter all subject name components. Note also that you can enter multiple values of each type.

    • domain-name — FQDN. The FQDN provides the identity of the certificate owner for IKE negotiations and provides an alternative to the subject name.

    • filename (path | terminal) — (Optional) Location where the certificate request should be placed, or the login terminal.

    • ip-address — (Optional) IP address of the device.

    • email — (Optional) e-mail address of CA administrator.


      You must use one of: domain-name, ip-address, or e-mail address.

    The domain-name, ip-address, or e-mail address defines the IKE ID type. The IKE ID type is configured in the IKE gateway profile in step 22.

    The generated certificate request is stored in a specified file location. A local copy of the certificate request is saved in the local certificate storage. If the administrator reissues this command, the certificate request is generated once again.

    The PKCS10 certificate request is stored in a specified file and location, from which you can download it and send it to the CA for enrollment. If you have not specified the file name or location, you can get PKCS10 certificate request details by using the show security pki certificate-request certificate-id <id-name> command in the CLI. You can copy the command output and paste it into a Web front-end for the CA server or into an e-mail.

  8. Submit the certificate request to the CA, and retrieve the certificate.

    The administrator submits the certificate request to the CA. The CA administrator verifies the certificate request and generates a new certificate for the Junos OS device. The Junos OS device administrator retrieves it, along with the CA certificate and CRL.

    The process of retrieving the CA certificate, the device’s new local certificate, and the CRL from the CA depends on the CA configuration and software vendor in use.

    For more information on how to retrieve the certificates, see Appendix B: Administering Common Certificate Authorities.


    Junos OS supports the following CA vendors:

    • Entrust

    • Verisign

    • Microsoft

    Although other CA software services such as OpenSSL can be used to generate certificates, these certificates are not verified by Junos OS.

    Junos OS may extend support to other vendors that conform to X.509 certificate standards.

  9. Load the local certificate, CA certificate, and CRL.

    The retrieved certificates (local certificate, CA certificate and CRL) should be loaded into the Junos OS device through FTP using the CLI.

    Assume the following names for certificates:

    • local certificate — certnew.cer

    • CA certificate — CA-certnew.cer

    • CRL — certcrl.crl


    You can verify that all files have been uploaded by using the command file list.

  10. Load the certificate into local storage from the specified external file.

    You must also specify the certificate-ID in order to keep the proper linkage with the private/public key pair. This step loads the certificate into the RAM cache storage of the PKI module, checks the associated private key, and verifies the signing operation.

  11. Load the CA certificate from the specified external file.

    You must specify the CA profile to associate the CA certificate to the configured profile.

  12. Load the CRL into the local storage.

    The allowed maximum size of the CRL is 5 MB. You must specify the associated CA profile in the command.

  13. Verify that all certificates are loaded.

    You can display the details of all local certificates in the CLI interface.


    You can display the individual certificate details by specifying certificate-ID in the command line. Also, you can select the output format as either brief or detail.

  14. View the CA certificates.

    Display all CA certificates or the CA certificates of an individual CA profile (specified).

  15. View the CRL.

    Display all loaded CRLs or the CRLs of the specified individual ca-profile.


    You can select the output format as brief or detail to display CRL information; at present both options provide the same output.

  16. Verify the certificate path for the local certificate and CA certificate.

  17. Use the certificates in an IPsec VPN.


    The steps for configuring a VPN using a certificate are similar to the steps for configuring a VPN using preshared keys. The only difference is the authentication method used for the IKE (Phase 1) policy. No changes are required for the IPsec (Phase 2) configuration because the use of certificates is part of Phase 1 negotiations.

    The following configuration steps describe how to configure a policy-based VPN as this method is most commonly used for dial-up VPNs.


    For more information on VPN configuration, see the Junos OS Enhanced Services Configuration Guides.


    For more information on Junos OS Enhanced Services Application Notes, see KB10182 ( available at Juniper Networks Knowledge Base.

    Step-by-Step Procedure

    To configure the IPsec VPN with the certificate:


    Refer to the network diagram shown in Figure 1 to complete the following steps.

    1. Configure the security zones, and bind the interfaces to the appropriate zones. Make sure that all necessary host-inbound services are enabled on the interfaces or zones. In this example, enable Internet IKE service either on the ge-0/0/3 interface or on the untrust zone.

    2. Configure address book entries for each zone for the tunnel policies.

    3. Configure the IKE (Phase 1) proposals to use RSA encryption.

    4. Configure an IKE policy specifying the RSA proposal, local certificate, CA certificate, and x.509 type peer certificate.

    5. Configure the IKE gateway settings specifying the IKE policy, and a dynamic peer identified by the hostname.

      This step depends on how the certificate request was generated earlier. In this example, “” was specified during the certificate request by the SSG5, which means that the IKE ID type is hostname.

    6. Configure the IPsec (Phase 2) VPN settings.

      Optionally you can also configure VPN monitor settings if required. In this example the Standard proposal set and PFS group 2 are used; however, you can create a different proposal if necessary.

    7. Configure tunnel policies to permit remote office traffic into the host LAN and vice versa. Also configure an outgoing “trust” to “untrust” permit-all policy with source NAT for Internet traffic. Be sure that the tunnel policy is above the permit-all policy. Otherwise the policy lookup will never reach the tunnel policy.

    8. Configure the TCP maximum segment size (tcp-mss) for IPsec traffic to eliminate the possibility of fragmented TCP traffic. This step reduces the resource usage on the device.

  18. Configure security zones and assign interfaces to the zones.

    The ingress (incoming) and egress (outgoing) zones are determined by the ingress and egress interfaces involved in the route lookup.

    In this example packets are incoming on ge-0/0/0, and the ingress zone is the trust zone.

    Following the route lookup, the egress interface is ge-0/0/3, and the egress zone is the untrust zone. So the tunnel policy should be configured as “from-zone trust to-zone untrust” and vice versa.

  19. Configure host-inbound services for each zone.

    Host-inbound services are for traffic destined for the Junos OS device. These settings include but are not limited to the FTP, HTTP, HTTPS, IKE, ping, rlogin, RSH, SNMP, SSH, Telnet, TFTP, and traceroute.

    This example assumes that all host-inbound services should be allowed from zone trust. For security reasons, we are allowing IKE only on the Internet-facing zone untrust which is required for IKE negotiations to occur. However, other services, such as services for management or troubleshooting can also be individually enabled if required.

  20. Configure the address book entries for each zone.

    This example uses address book object names local-net and remote-net. There are some limitations with regard to which characters are supported for address book names. Please refer to the complete Junos OS documentation for more details.

  21. Configure the IKE (Phase 1) proposal to use RSA encryption.

    This example uses 3DES encryption, the SHA1 authentication algorithm, and Diffie-Hellman Group 2 keys.

  22. Configure an IKE policy.

    The phase 1 exchange can take place in either main mode or aggressive mode.

    Main mode is typically used for site-to-site VPNs with static IP peers. Aggressive mode is used for dynamic IP and dial-up peers.

    This example uses main mode because both sides have static IP addresses even though the hostname (typically used for dynamic tunnels) is used here for the IKE ID.

  23. Configure an IKE gateway.

    A remote IKE peer can be identified by IP address, FQDN/U-FQDN, or ASN1-DN (PKI certificates).

    In this example, the peer is identified by an FQDN (hostname). Therefore the gateway IKE ID should be the remote peer domain name. You must specify the correct external interface or peer ID to properly identify the IKE gateway during Phase 1 setup.

  24. Configure the IPsec policy.

    This example uses the Standard proposal set, which includes esp-group2-3des-sha1 and esp-group2- aes128-sha1 proposals. However, a unique proposal may be created and then specified in the IPsec policy if needed.

  25. Configure the IPsec VPN with an IKE gateway and IPsec policy.

    In this example, the ike-vpn VPN name must be referenced in the tunnel policy to create a security association. Additionally, if required, an idle time and a proxy ID can be specified if they are different from the tunnel policy addresses.

  26. Configure bidirectional tunnel policies for VPN traffic.

    In this example, traffic from the host LAN to the remote office LAN requires a “from-zone trust to-zone untrust” tunnel policy. However if a session needs to originate from the remote LAN to the host LAN, then a tunnel policy in the opposite direction “from-zone untrust to-zone trust” is also required. By specifying the policy in the opposite direction as the pair-policy, the VPN becomes bidirectional. Note also that in addition to the permit action, you also need to specify the IPsec profile to be used. Furthermore source NAT can be enabled on the policy if desired, but that is beyond the scope of this application note. Note that for tunnel policies, the action is always permit. In fact if you are configuring a policy with action of deny, you will not see an option for specifying the tunnel.

  27. Configure a security policy for Internet traffic.

    A security policy is required to permit all traffic from zone trust to zone untrust.

    The device uses the specified source-nat interface, and translates the source IP address and port for outgoing traffic, using the IP address of the egress interface as the source IP address and a random higher port for the source port. If required, more granular policies can be created to permit/deny certain traffic.

  28. Note that the security policy should be below the tunnel policy in the hierarchy because the policy list is read from top to bottom. If this policy were above the tunnel policy, then the traffic would always match this policy and would not continue to the next policy. Thus no user traffic would be encrypted. To move the tunnel policy above the any-permit policy, use the insert policy command as shown below:

  29. Configure the tcp-mss setting for TCP traffic across the tunnel.

    TCP-MSS is negotiated as part of the TCP 3-way handshake. It limits the maximum size of a TCP segment to accommodate the maximum transmission unit (MTU) limits on a network. This is very important for VPN traffic as the IPsec encapsulation overhead along with the IP and frame overhead can cause the resulting ESP packet to exceed the MTU of the physical interface, causing fragmentation. Fragmentation increases the bandwidth and device resources usage, and it should always be best avoided.

    The recommended value to use for tcp-mss is 1350 for most Ethernet-based networks with an MTU of 1500 or higher. This value may need to be altered if any device in the path has a lower value of MTU or if there is any added overhead such as PPP, Frame Relay, and so on. As a general rule, you may need to experiment with different tcp-mss values to obtain optimal performance.

  30. This step provides information on SSG device configuration. Because the focus of this example is on Junos OS configuration and troubleshooting, the SSG device configuration is explained briefly in this step.

    To show the configuration settings in Figure 1, a sample of the relevant configurations is provided from an SSG5 device strictly for reference.

    However, the concepts with regard to configuration of policy-based VPNs for Juniper Networks Firewall/VPN products are available in the Concepts and Examples (C&E) guides. For more information, see the Concepts & Examples ScreenOS Reference Guide available at

    The following example is a relevant sample of an SSG5 configuration:


Verification and troubleshooting of the IKE and IPsec are similar to that site-to-site VPNs using preshared keys except for the use of the certificate for IKE identification, authentication, and encryption methods.

For more information, see the following:

Use the following steps to verify the IKE and IPsec configuration:

Confirm IKE Phase 1 Status


To confirm the VPN status by checking any IKE Phase 1 security associations status.

PKI related to IPsec tunnels is formed during Phase 1 setup. Completion of Phase 1 indicates that PKI was successful.



The output indicates that

  • The remote peer is and the status is UP, which means the successful association of Phase 1 establishment.

  • The remote peer IKE ID, IKE policy, and external interfaces are all correct.

  • Index 20 is unique value for each IKE security association. You can use this output details to get further details on each security association. See Get Details on Individual Security Associations.

Incorrect output would indicate that:

  • The remote peer status as Down.

  • There are no IKE security associations .

  • There are IKE policy parameters, such as the wrong mode type (Aggr or Main), PKI issues, or Phase 1 proposals (all must match on both peers). For more information, see Troubleshooting IKE, PKI, and IPsec Issues.

  • External interface is invalid for receiving the IKE packets. Check the configurations for PKI-related issues or check kmd log for any other errors or run traceoptions to find the mismatch. For more information, see Troubleshooting IKE, PKI, and IPsec Issues.

Get Details on Individual Security Associations


Get details on individual IKE security associations (SAs).



The output displays the details of the individual IKE SAs such as role (initiator or responder), status, exchange type, authentication method, encryption algorithms, traffic statistics, Phase 2 negotiation status, and so on.

You can use the output data to:

  • Know the role of the IKE SA. Troubleshooting is easier when the peer has the responder role.

  • Get the traffic statistics to verify the traffic flow in both directions.

  • Get the number of IPsec security associations created or in progress.

  • Get the status of any completed Phase 2 negotiations.

Confirming IPsec Phase 2 Status


View IPsec (Phase 2) security associations.

Phase 2 happens same was as it does with non-certificate-based VPNs.

When IKE Phase 1 is confirmed, view the IPsec (Phase 2) security associations.



The output indicates that

  • There is a configured IPsec SA pair available . The port number 500 indicates that a standard IKE port is used. Otherwise, it is Network Address Translation-Traversal (NAT-T), 4500, or random high port.

  • The security parameter index (SPI) is used for both directions. The lifetime or usage limits of the SA is expressed either in seconds or in kilobytes. In the output, 1676/ unlim indicates Phase 2 lifetime is set to expire in 1676 seconds and there is no specified lifetime size.

  • The ID number shows the unique index value for each IPsec SA.

  • A hyphen (-) in the Mon column indicates that VPN monitoring is not enabled for this SA.

  • The virtual system (vsys) is zero, which is the default value.


Phase 2 lifetime can be different from the Phase 1 lifetime because Phase 2 is not dependent on Phase 1 after the VPN is up.


For information on VPN monitoring, refer to the complete documentation for Junos OS available at

Display IPsec Security Association Details


Display the individual IPsec SA details identified by the index number.



The output displays the local Identity and the remote Identity.

Note that a proxy ID mismatch may cause Phase 2 completion to fail. The proxy ID is derived from the tunnel policy (for policy-based VPNs). The local address and remote address are derived from the address book entries, and the service is derived from the application configured for the policy.

If Phase 2 fails due to a proxy ID mismatch, verify which address book entries are configured in the policy and ensure that the correct addresses are sent. Also ensure that the ports are matching. Double-check the service to ensure that the ports match for the remote and local servers.


If multiple objects are configured in a tunnel policy for source address, destination address, or application then the resulting proxy ID for that parameter is changed to zeroes.

For example, assume the following scenario for a tunnel policy:

  • Local addresses of and

  • Remote address of

  • Application as junos-http

The resulting proxy ID is local, remote, service 80.

The resulting proxy IDs can affect the interoperability if the remote peer is not configured for the second subnet. Also if you are employing a third-party vendor’s application, you may have to manually enter the proxy ID to match.

If IPsec fails to complete, then check the kmd log or set traceoptions. For more information, see Troubleshooting IKE, PKI, and IPsec Issues.

Check IPsec SA Statistics


Check statistics and errors for an IPsec SA.

For troubleshooting purpose, check the Encapsulating Security Payload/Authentication Header (ESP/AH) counters for any errors with a particular IPsec SA.



An error value of zero in the output indicates a normal condition.

We recommend running this command multiple times to observe any packet loss issues across a VPN. Output from this command also displays the statistics for encrypted and decrypted packet counters, error counters, and so on.

You must enable security flow traceoptions to investigate which ESP packets are experiencing errors and why. For more information, see Troubleshooting IKE, PKI, and IPsec Issues.

Test Traffic Flow Across the VPN


Test traffic flow across the VPN after Phase 1 and Phase 2 have completed successfully. You can test traffic flow by using the ping command. You can ping from local host to remote host. You can also initiate pings from the Junos OS device itself.

This example shows how to initiate a ping request from the Junos OS device to the remote host. Note that when pings are initiated from the Junos OS device, the source interface must be specified to ensure that the correct route lookup takes place and the appropriate zones are referenced in the policy lookup.

In this example, the ge-0/0/0.0 interface resides in the same security zone as the local host and must be specified in the ping request so that the policy lookup can be from zone trust to zone untrust.


Confirm the Connectivity


Confirm the connectivity between a remote host and a local host.



You can confirm end-to-end connectivity by using the ping command from the remote host to the local host. In this example, the command is initiated from the SSG5 device.

Failed end-to-end connectivity may indicate an issue with routing, policy, end host, or encryption/decryption of the ESP packets. To verify the exact causes of the failure:

  • Check IPsec statistics for details on errors as described in Check IPsec SA Statistics .

  • Confirm end host connectivity by using the ping command from a host on the same subnet as the end host. If the end host is reachable by other hosts, then you can assume that the issue is not with the end host.

  • Enable security flow traceoptions for troubleshooting the routing-and -policy-related issues.

    The details are not covered in this example, but you can get more details in VPN-related application notes for Junos OS available at

Troubleshooting IKE, PKI, and IPsec Issues

The basic troubleshooting steps are as follows:

  1. Identifying and isolating the problem.

  2. Debugging the problem.

The common approach of starting troubleshooting is with the lowest layer of the OSI layers and working your way up the OSI stack to confirm the layer in which the failure occurs. The steps for troubleshooting IKE, PKI, and IPsec are as follows:

  • Confirm the physical connectivity of the Internet link at the physical and data link levels.

  • Confirm that the Junos OS device has connectivity to the Internet next hop and connectivity to the remote IKE peer.

  • Confirm IKE Phase 1 completion.

  • Confirm IKE Phase 2 completion if IKE Phase 1 completion is successful.

  • Confirm the traffic flow across the VPN (if the VPN is up and active).

Junos OS includes the traceoptions feature. Using this feature, you can enable a traceoption flag to write the data from the traceoption to a log file, which may be predetermined or manually configured and stored in flash memory. These trace logs can be retained even after a system reboot. Check the available flash storage before implementing traceoptions.

You can enable the traceoptions feature in configuration mode and commit the configuration to use the traceoptions feature. Similarly to disable traceoptions, you must deactivate traceoptions in configuration mode and commit the configuration.

Check the Free Disk Space on Your Device


Check the statistics on the free disk space in your device file systems.


The /dev/ad0s1a represents the onboard flash memory and is currently at 35% capacity.


You can view the available system storage in the J-Web interface under the System Storage option.


You can enable traceoptions to log the trace data to the filenames specified or to the default log file to receive the output of the tracing operation.

The output of the traceoptions is placed in /var/log/kmd.

Check the Log Files to Verify Different Scenarios and Upload Log Files to an FTP


View the log files to check security IKE debug messages, security flow debugs, and the state of logging to the syslog.



You can view a list of all logs in the /var/log directory by using the show log command.

Log files can also be uploaded to an FTP server by using the file copy command.

Enable IKE Traceoptions to View Messages on IKE


To view success or failure messages for IKE or IPsec, you can view the key management process (kmd) log by using the show log kmd command. Because the kmd log displays some general messages, it may be useful to obtain additional details by enabling IKE and PKI traceoptions.


Generally, it is best practice to troubleshoot the peer which has the responder role. You must obtain the trace output from the initiator and responder to understand the cause of a failure.

Configure IKE tracing options.



If you do not specify file names for the <filename> field, then all IKE traceoptions are written to the kmd log.

You must specify at least one flag option to write trace data to the log. For example:

  • file size — Maximum size of each trace file, in bytes. For example 1m or 1000000 can generate a maximum file size of 1 MB.

  • files — Maximum number of trace files to be generated and stored in flash.


You must commit your configuration to start the trace.

Enable PKI Traceoptions to View Messages on IPsec


Enable PKI traceoptions to identify whether an IKE failure is related to the certificate or to a non-PKI issue.


Setting up IKE and PKI Traceoptions to Troubleshoot IKE Setup Issues with Certificates


Configure the recommended settings for IKE and PKI traceoptions.


The IKE and PKI traceoptions use the same parameters, but the default filename for all PKI-related traces is found in the pkid log.


Analyzing the Phase 1 Success Message


Understand the output of the show log kmd command where the IKE Phase 1 and Phase 2 conditions are successful.


The sample output indicates:

  • — Local address.

  • — Remote peer (hostname with FQDN).

  • udp: 500 — Indicates that no NAT-T was negotiated.

  • Phase 1 [responder] done — Indicates the Phase 1 status, along with the role (initiator or responder).

  • Phase 2 [responder] done — Indicates the Phase 1 status with proxy ID information.

    You can also confirm the IPsec SA status by using the verification commands mentioned in Confirm IKE Phase 1 Status.

Analyzing the Phase 1 Failure Message (Proposal Mismatch)


Understand the output of the show log kmd command, where the IKE Phase 1 condition is a failure. This procedure helps in determining the reason for the VPN not establishing Phase 1.


The sample output indicates that

  • — Is the local address

  • — Indicates the remote peer (hostname with FQDN)

  • udp: 500 — Indicates that no NAT-T was negotiated.

  • Phase-1 [responder] failed with error (No proposal chosen) — Indicates Phase 1 failure because of proposal mismatch.

To resolve this issue, ensure that the parameters for the IKE gateway Phase 1 proposals on both the responder and the initiator match. Also confirm that a tunnel policy exists for the VPN.

Analyzing the Phase 1 Failure Message (Authentication Failure)


Understand the output of the show log kmd command when the IKE Phase 1 condition is a failure. This helps in determining the reason for the VPN not establishing Phase 1.


The sample output indicates that

  • — Is the local address

  • — Is the remote peer

  • Phase 1 [responder] failed with error (Authentication failed) — Indicates Phase 1 failure due to the responder not recognizing the incoming request originating from a valid gateway peer. In the case of IKE with PKI certificates, this failure typically indicates that an incorrect IKE ID type was specified or entered.

To resolve this issue, confirm that the correct peer IKE ID type is specified on the local peer based on the following:

  • How the remote peer certificate was generated

  • SubjectAlternativeName or DN information in the received remote peer certificate

Analyzing the Phase 1 Failure Message (Timeout Error)


Understand the output of the show log kmd command when the IKE Phase 1 condition is a failure.


The sample output indicates that:

  • — Is the local address

  • — Is the remote peer

  • Phase 1 [responder] failed with error(Timeout) — Indicates Phase 1 failure.

    This error indicates that either the IKE packet is lost enroute to the remote peer or there is a delay or no response from the remote peer.

Because this timeout error is the result of waiting on a response from the PKI daemon, you must review the PKI traceoptions output to see whether there is a problem with PKI.

Analyzing the Phase 2 Failure Message


Understand the output of the show log kmd command when the IKE Phase 2 condition is a failure.


The sample output indicates that

  • — Is the local address.

  • — Is the remote peer (IKE ID type hostname with FQDN).

  • Phase 1 [responder] done — Indicates Phase 1 success.

  • Failed to match the peer proxy ids — Indicates that the incorrect proxy IDs are received. In the previous sample, the two proxy IDs received are (remote) and (local) (for service=any). Based on the configuration given in this example, the expected local address is This shows that there is a mismatch of configurations on the local peer, resulting in the failure of proxy ID match.

    To resolve this issue, correct the address book entry or configure the proxy ID on either peer so that it matches the other peer.

    The output also indicates the reason for failure is No proposal chosen. However in this case you also see the message Failed to match the peer proxy ids.

Analyzing the Phase 2 Failure Message


Understand the output of the show log kmd command when the IKE Phase 2 condition is a failure.


The sample output indicates that:

  • — Is the local address.

  • fqdn(udp:500,[0..15] — Is the remote peer.

  • Phase 1 [responder] done — Indicates Phase 1 success.

  • Error = No proposal chosen — Indicates that no proposal was chosen during Phase 2. This issue is due to proposal mismatch between the two peers.

    To resolve this issue, confirm that the Phase 2 proposals match on both peers.

Common Problems Related to IKE and PKI


Troubleshoot common problems related to IKE and PKI.

Enabling the traceoptions feature helps you to gather more information on the debugging issues than is obtainable from the normal log entries. You can use the traceoptions log to understand the reasons for IKE or PKI failures.

For detailed analysis on the IKE and PKI problems and traceoptions outputs, contact Juniper Networks JTAC Support or visit the Juniper Networks Support Website at for further assistance.


Methods for troubleshooting the IKE -and-PKI-related issues:

  • Ensure that the clock, date, time zone, and daylight savings settings are correct. Use NTP to keep the clock accurate.

  • Ensure that you use a two-letter country code in the "C=" (country) field of the DN.

    For example: use “US” and not “USA” or “United States.” Some CAs require that the Country field of the DN be populated, allowing you to enter the country code value only with a two-letter value.

  • Ensure that if a peer certificate is using multiple OU= or CN= fields, you are using the distinguished name with container method (the sequence must be maintained and is case sensitive).

  • If the certificate is not valid yet, check the system clock and, if required, adjust the system time zone or just add a day in the clock for a quick test.

  • Ensure that a matching IKE ID type and value are configured.

  • PKI may fail due to a revocation check failure. To confirm this, temporarily disable revocation check and see whether IKE Phase 1 is able to complete.

    To disable revocation checking, use the following command in configure mode:

    set security pki ca-profile <ca-profile> revocation-check disable