일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Xcode
- 앨범북
- MSYS2
- MYSQL
- SwiftUI
- Nodejs
- 앱스토어
- WebAuthn
- albumbook
- OSX
- Android
- OTP
- 안드로이드
- git
- FIDO2
- css
- 애플
- SSL
- apple
- otpkey
- SSH
- 2FA
- 앱리소스
- MFA
- kmip
- SWIFT
- openssl
- 인증
- appres
- fido
Archives
- Today
- Total
인디노트
OPENSSL PKI pem_password_cb 구현등 본문
int pass_cb(char *buf, int size, int rwflag, void *u)
{
/* We'd probably do something else if 'rwflag' is 1 */
printf("Enter pass phrase for \"%s\"\n", (char *)u);
/* get pass phrase, length 'len' into 'tmp' */
char *tmp = "hello";
if (tmp == NULL) /* An error occurred */
return -1;
size_t len = strlen(tmp);
if (len > size)
len = size;
memcpy(buf, tmp, len);
return len;
}
그 이외 샘플
EXAMPLES
Although the PEM routines take several arguments in almost all applications most of them are set to 0 or NULL.
Read a certificate in PEM format from a BIO:
X509 *x;
x = PEM_read_bio_X509(bp, NULL, 0, NULL);
if (x == NULL)
/* Error */
Alternative method:
X509 *x = NULL;
if (!PEM_read_bio_X509(bp, &x, 0, NULL))
/* Error */
Write a certificate to a BIO:
if (!PEM_write_bio_X509(bp, x))
/* Error */
Write a private key (using traditional format) to a BIO using triple DES encryption, the pass phrase is prompted for:
if (!PEM_write_bio_PrivateKey(bp, key, EVP_des_ede3_cbc(), NULL, 0, 0, NULL))
/* Error */
Write a private key (using PKCS#8 format) to a BIO using triple DES encryption, using the pass phrase "hello":
if (!PEM_write_bio_PKCS8PrivateKey(bp, key, EVP_des_ede3_cbc(),
NULL, 0, 0, "hello"))
/* Error */
Read a private key from a BIO using a pass phrase callback:
key = PEM_read_bio_PrivateKey(bp, NULL, pass_cb, "My Private Key");
if (key == NULL)
/* Error */
Skeleton pass phrase callback:
int pass_cb(char *buf, int size, int rwflag, void *u)
{
/* We'd probably do something else if 'rwflag' is 1 */
printf("Enter pass phrase for \"%s\"\n", (char *)u);
/* get pass phrase, length 'len' into 'tmp' */
char *tmp = "hello";
if (tmp == NULL) /* An error occurred */
return -1;
size_t len = strlen(tmp);
if (len > size)
len = size;
memcpy(buf, tmp, len);
return len;
}
반응형
'인증기술 > PKI 기술' 카테고리의 다른 글
Forge PKCS#8 - 개인키의 포맷변환 및 암호화 저장 (0) | 2022.08.07 |
---|---|
Java BouncyCastleProvider 가 설정되어 있는지 확인 후 설정 (0) | 2022.07.17 |
PEM_write_bio_RSAPublicKey vs PEM_write_bio_RSA_PUBKEY (0) | 2022.07.17 |
안드로이드 개인 인증서 추가 관련 정보 (0) | 2018.12.27 |
Simple Certificate Enrollment Protocol (SCEP) (0) | 2018.10.10 |
Comments