Redirect HTTP requests to HTTPS

I modified initchannel() method in the netty4HttpServerTransport file , https is working fine,but i want to redirect http to https..
The code is,
char password = "your5663".toCharArray();
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(new FileInputStream("C:/OpenSSL-Win64/bin/keystore1.jks"),password);

KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init(ks, password);

	    TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
	    tmf.init(ks);
	    TrustManager[] tm = tmf.getTrustManagers();

	    SSLContext sslContext  = SSLContext.getInstance("TLSv1.3");
	    sslContext .init( kmf.getKeyManagers(), tm, null);
	    SSLEngine sslengine = sslContext .createSSLEngine();
	    
	    sslengine.setUseClientMode(false);
        
	    String[] DEFAULT_PROTOCOLS = { "TLSv1", "TLSv1.1", "TLSv1.2","TLSv1.3" };
	    String[] DEFAULT_CIPHERS = {"TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_128_CBC_SHA"};
	    
	    sslengine.setEnabledProtocols(DEFAULT_PROTOCOLS);
	    sslengine.setEnabledCipherSuites(DEFAULT_CIPHERS);
	    
	    SslHandler sslHandler = new SslHandler(sslengine);
        ch.pipeline().addLast("ssl", sslHandler);      
        ch.pipeline().addAfter("ssl","handshake",new StringEventHandler());

What do i have to add to redirect http trafic to https.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.