[Android] Keystore 보안

2020. 11. 17. 21:54

Keystore 보안


 

앱을 배포하기 위해 apk 또는 aab에 앱서명을 하게되면 build.gradle에

Keystore의 Alias, password, File경로가 나타나게 됩니다.

signingConfigs {
	release {
        	storeFile file('keystore 경로')
        	storePassword '비밀번호'
    		keyAlias 'key()'
        	keyPassword '비밀번호'
	}
}

 

이와 같이 keystore의 정보가 노출된 상태로 Github나 기타 사이트에 업로드되면 악용될 수 있습니다.

그러므로 별도의 keystore file을 만들어 보안을 강화하는 것을 권장합니다.

 

- 프로젝트 탭을 선택하신 후 루트디렉토리에다가 keystore.properties파일을 만들어줍니다.

 

- keystore.properties 작성

파일 내부에 keystore 값들을 작성해줍니다.

 

storeFile = 경로
storePassword = 비밀번호
keyAlias = 별칭
keyPassword = 비밀번호

 

- build.gradle 작성

상단에 apply와 android 사이에 keystore.properties의 값들을 불러오는 작업을 해줍니다.

// Keystore Security
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))

 

- signingConfigs 내부 수정

기존의 값들을 keystoreProperties['keyPassword']와 같이 바꿔주시면 됩니다.

signingConfigs {
	debug {
		storeFile file(keystoreProperties['storeFile'])
        	storePassword keystoreProperties['storePassword']
        	keyAlias keystoreProperties['keyAlias']
        	keyPassword keystoreProperties['keyPassword']
	}
}

 

 

 

이제 깃허브나 기타 사이트에 업로드하실 때 keystore.properties파일을 제외하고 업로드하시면 됩니다 :)


+ Recent posts