Why does SSL handshake give 'Could not generate DH keypair' exception?

前端 未结 21 1229
梦如初夏
梦如初夏 2020-11-22 07:46

When I make an SSL connection with some IRC servers (but not others - presumably due to the server\'s preferred encryption method) I get the following exception:

<         


        
21条回答
  •  广开言路
    2020-11-22 08:27

    I have the same problem with Yandex Maps server, JDK 1.6 and Apache HttpClient 4.2.1. The error was

    javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
    

    with enabled debug by -Djavax.net.debug=all there was a message in a log

    Could not generate DH keypair
    

    I have fixed this problem by adding BouncyCastle library bcprov-jdk16-1.46.jar and registering a provider in a map service class

    public class MapService {
    
        static {
            Security.addProvider(new BouncyCastleProvider());
        }
    
        public GeocodeResult geocode() {
    
        }
    
    }
    

    A provider is registered at the first usage of MapService.

提交回复
热议问题