Push 기능 구현중에 ATP 서버에 올린  Push 실행시 동작이 잘되나

로컬에서Push 실행시, 아이폰 푸시처리 중에 에러가 발생했던 부분에 대한 해결방법이다.

 

에러 발생 부분 : /??/??/??/IPhonePush.java, 73 line

 

pushManager.initializeConnection(host, port, certificateStream, certificatePassword,

            SSLConnectionHelper.KEYSTORE_TYPE_PKCS12);


에러 메시지

 

java.io.IOException: exception decrypting data - java.security.InvalidKeyException: Illegal key size

또는

java.io.IOException: exception decrypting data - java.security.InvalidKeyException: default parameters

 

 

원인 : JDK 1.4.x부터는 JCE가 기본적으로 포함이 되어 있으며 미국 수출 통상법에 따라 사용할 수 있는 키 길이 등에 제한이 걸려 있다.

Within the libraries of the Java Cryptography Extension (JCE), you'll find support for encryption, decryption, key agreement, Message Authentication Code (MAC), and some other cryptographic services. Due to import control restrictions of some countries, the JCE jurisdiction policy files shipped with the Java 2 SDK, release 1.4 allow "strong" but limited cryptography to be used. An "unlimited strength" version of these files indicating no restrictions on cryptographic strengths is available for those living in eligible countries (most countries). You can download this version and replace the string cryptography versions supplied with the Java 2 SDK, release 1.4 with the unlimited ones.


해결방법 : 제한이 없는 정책파일로 변경하면 된다.

 

https://t1.daumcdn.net/cfile/tistory/1934EE4C4F19243E02



오라클 홈페이지에 다운로드로 가셔서
 Java for Developers 로 이동합니다.

https://t1.daumcdn.net/cfile/tistory/1134EE4C4F19243F03


다운로드 탭을 선택 후 아래쪽으로 쭈~욱 이동하시면

https://t1.daumcdn.net/cfile/tistory/1234EE4C4F19243F04

http://www.oracle.com/technetwork/java/javase/downloads/index.html (페이지 최하단)


위와 같이 제한없는 정책파일을 다운받으실 수 있다
알맞은 정책파일을 다운 받는다

JDK
 JRE가 설치된 곳의 해당 위치에 있는 다음 파일을 덮어 쓰면 됩다.
=> C:\Program Files\Java\jdk1.6.0_29\jre\lib\security
=> C:\Program Files\Java\jre6\lib\security

정책파일
 : local_policy.jar, US_export_policy.jar

제한 정책 파일에 의해 허가된 최대 키 사이즈

Algorithm

Maximum Keysize

DES

64

DESede

*

RC2

128

RC4

128

RC5

128

RSA

*

all others

128


Java  Cryptography Architecture (JCA) Reference Guide
http://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html

 

 

Posted by CJ.Ree
,

IOS Push 발송기능이 포함된 웹 어플리케이션을 로컬 및 개발서버에서 테스트 한 후에 Live 서버의 Jboss-as 서버위에 Deploy 하였다.

헌데 아래와 같은 오류가 발생하면서 Push 전송이 안된다.

국내 사이트에서는 관련 정보가 없어 구글링을 해본결과 프로바이더관련 에러인것으로 확인되었다.

근데 프로바이더가 머지?

일단 급한 불부터 끄기러 하고 아래사이트를 참고 하여 해결책을 따라하였다.


http://www.randombugs.com/java/javalangsecurityexception-jce-authenticate-provider-bc.html
(http://blog.naver.com/arad21?Redirect=Log&logNo=130077580236)


1. Find java.security in /path_to_your_jvm/jre/lib/security
2. Add security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

Your file should look like

security.provider.1=sun.security.provider.Sun
security.provider.2=sun.security.rsa.SunRsaSign
security.provider.3=com.sun.net.ssl.internal.ssl.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
security.provider.6=com.sun.security.sasl.Provider
security.provider.7=org.jcp.xml.dsig.internal.dom.XMLDSigRI
security.provider.8=sun.security.smartcardio.SunPCSC
security.provider.9=org.bouncycastle.jce.provider.BouncyCastleProvider

If you don’t have all those security providers then change security.provider.9 with your next number from security.provider, don’t use 9.
3. add the bcprov-jdk16-143.jar, bcmail-jdk16.143 and any other BC library to /path_to_your_jvm/jre/lib/ext

4. Remove any other BC library from your class path.


2번항목에서 security.provider.1~8 까지는 애초에 존재하는 코드이고,

security.provider.9 가 존재하지 않아 추가하였다.

그리고 3번항목에 해당하는 파일들을 아래사이트에서 다운받아 지시한 디렉토리에 추가하였다.

(http://www.bouncycastle.org/fr/example.html)

다운 BC 파일들 (JDK 1.6 관련 BC*) : 
bcprov-jdk16-146.jar   
bcmail-jdk16-146.jar 
bctsp-jdk16-146.jar 
bcpg-jdk16-146.jar 
bctest-jdk16-146.jar

이후 JBoss를 재가동하니 관련 이슈 해결!! 하지만 다음 이슈가 기다리고 있었으니....ㅠㅠ


기타 참고 :

https://jira.primekey.se/browse/ECA-1113

https://community.jboss.org/message/541468


System.exit(0);
by  CJ.Lee

'TroubleShooting' 카테고리의 다른 글

java.security.InvalidKeyException: Illegal key size  (0) 2012.08.19
Posted by CJ.Ree
,