Giter Club home page Giter Club logo

Comments (15)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Something is wrong with your cert.

Where are you storing the cert? In what format? How did it get there? etc....

Original comment by [email protected] on 24 May 2011 at 9:10

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Same problem here.  It worked fine on a different machine, so I'm not sure 
what's wrong.

I'm storing the certificate as a file, "testcert.p12".  I emailed it to myself 
from the machine I made it on (Keychain app -> select developer and push cert, 
export).  I've re-made and re-emailed it to myself so I don't think it was a 
transmission error.  I'm working with Eclipse Helios on a Windows 7 machine, 
with JDK 1.5.

Original comment by [email protected] on 3 Aug 2011 at 6:05

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
I assume you are using the jdk 1.5 version.

Sounds like the SSL certificate isn't loading properly... what happens when you 
enable ssl certificate logging as per:
http://code.google.com/p/javapns/wiki/Tips

Original comment by [email protected] on 3 Aug 2011 at 2:43

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
You say you 'emailed it to myself'...

Are you sure the file didn't get binhex encoded or modified in transit?

Does the filesize match on the originating machine and target machine?

Can you find a better way to copy the file? ftp? winscp? sneakernet?

Can you verify that java can load the file at all?

Original comment by [email protected] on 3 Aug 2011 at 5:10

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
bdares, were you able to solve the issue you reported?  Was it related to your 
keystore format or password?  May we close this issue as fixed?  Thank you!

Original comment by [email protected] on 7 Sep 2011 at 3:47

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024

Original comment by [email protected] on 9 Sep 2011 at 7:18

  • Changed title: javax.crypto.BadPaddingException: Given final block not properly padded

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Issue suspected of being caused by invalid password for given keystore.

Closing issue as no feedback was received by original poster since issue was 
reported.  
Please feel free to re-open if the issue is still valid.

Original comment by [email protected] on 14 Sep 2011 at 4:00

  • Changed state: Invalid

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
if we wanna decrypt a encrypted file than this exception arise (file is 
encrypted). 
but if we encrypt file n thank decrypt in same code thank code execute 
successfully

can some help me please

Original comment by [email protected] on 19 Oct 2011 at 7:35

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
I do not understand what you mean.  Please provide a copy of the code you are 
trying to run, and the exception (with stack trace) you are getting.  Thank you.

Original comment by [email protected] on 19 Oct 2011 at 2:34

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
[deleted comment]

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
[deleted comment]

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
    public static void main(String[] args) throws Exception {
        InputStream in = new FileInputStream(new File("C:/user.p12"));
        KeyStore ks = java.security.KeyStore.getInstance("PKCS12");
        ks.load(in,"user".toCharArray());
        in.close();
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
        tmf.init(ks);
        X509TrustManager defaultTrustManager = (X509TrustManager)tmf.getTrustManagers()[0];
        SSLContext context =SSLContext.getInstance("TLS");
        context.init(null, new TrustManager[]{defaultTrustManager}, null);
        SSLSocketFactory sslSocketFactory = context.getSocketFactory();

        URL url = new URL("https://192.168.1.1:8443/test/test");
        URLConnection conn = url.openConnection();
        ((HttpsURLConnection) conn).setHostnameVerifier(new javax.net.ssl.HostnameVerifier() {


            @Override
            public boolean verify(String arg0, SSLSession arg1) {
                // TODO Auto-generated method stub
                return true;
            }
        });
        ((HttpsURLConnection)conn).setSSLSocketFactory(sslSocketFactory);
        conn.connect();

I configure my tomcat using server.p12  , I get the following error


Exception in thread "main" java.io.IOException: failed to decrypt safe contents 
entry: javax.crypto.BadPaddingException: Given final block not properly padded
    at com.sun.net.ssl.internal.pkcs12.PKCS12KeyStore.engineLoad(Unknown Source)
    at java.security.KeyStore.load(Unknown Source)
    at testpack.Newtest.main(Newtest.java:24)
Caused by: javax.crypto.BadPaddingException: Given final block not properly 
padded
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)
    at com.sun.crypto.provider.PKCS12PBECipherCore.b(DashoA13*..)
    at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40.engineDoFinal(DashoA13*..)
    at javax.crypto.Cipher.doFinal(DashoA13*..)
    ... 3 more

Original comment by [email protected] on 23 Nov 2011 at 11:46

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
Your code is not even using the JavaPNS library...  Are you requesting support 
in a project you are not using?  Or am I missing something here...

Original comment by [email protected] on 23 Nov 2011 at 2:01

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
go to function extractPrivateKey()
and change alias and password

Original comment by [email protected] on 4 Oct 2013 at 10:43

from javapns.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 24, 2024
I want to encrypt with certificate private key (.pfx) and decrypt with public 
key.

Original comment by [email protected] on 3 Sep 2014 at 7:42

from javapns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.