0
내가 날짜를 만료 다음과 같은 기능
static NSDate *CertificateGetExpiryDate(X509 *certificateX509)
{
NSDate *expiryDate = nil;
if (certificateX509 != NULL) {
ASN1_TIME *certificateExpiryASN1 = X509_get_notAfter(certificateX509);
if (certificateExpiryASN1 != NULL) {
ASN1_GENERALIZEDTIME *certificateExpiryASN1Generalized = ASN1_TIME_to_generalizedtime(certificateExpiryASN1, NULL);
if (certificateExpiryASN1Generalized != NULL) {
unsigned char *certificateExpiryData = ASN1_STRING_data(certificateExpiryASN1Generalized);
// ASN1 generalized times look like this: "20131114230046Z"
// format: YYYYMMDDHHMMSS
// indices:
// 1111
// There are other formats (e.g. specifying partial seconds or
// time zones) but this is good enough for our purposes since
// we only use the date and not the time.
//
// (Source: http://www.obj-sys.com/asn1tutorial/node14.html)
NSString *expiryTimeStr = [NSString stringWithUTF8String:(char *)certificateExpiryData];
NSDateComponents *expiryDateComponents = [[NSDateComponents alloc] init];
expiryDateComponents.year = [[expiryTimeStr substringWithRange:NSMakeRange(0, 4)] intValue];
expiryDateComponents.month = [[expiryTimeStr substringWithRange:NSMakeRange(4, 2)] intValue];
expiryDateComponents.day = [[expiryTimeStr substringWithRange:NSMakeRange(6, 2)] intValue];
expiryDateComponents.hour = [[expiryTimeStr substringWithRange:NSMakeRange(8, 2)] intValue];
expiryDateComponents.minute = [[expiryTimeStr substringWithRange:NSMakeRange(10, 2)] intValue];
expiryDateComponents.second = [[expiryTimeStr substringWithRange:NSMakeRange(12, 2)] intValue];
NSCalendar *calendar = [NSCalendar currentCalendar];
expiryDate = [calendar dateFromComponents:expiryDateComponents];
[expiryDateComponents release];
}
}
}
return expiryDate;
}
을 사용하고 날짜를 시작하지만 난 전체 세부 사항을 파서 인증서를 구문 분석 # import에 클래스를 이용하고 있고 얻을
등 일반적인 이름, 버전, 개인 키 같은 인증서의
은에 어떤 내가 그 일을 얻을 수있는 방법을 말씀 해주십시오 수
X509_NAME * issuerX509Name = X509_get_issuer_name (certificateX509); X509_NAME * subjectX509Name = X509_get_subject_name (certificateX509);
위의 두 함수와 함께 문제 이름과 제목을 얻고 있지만이 항목을 Nsstring 형식으로 변환하고 싶습니다.
아무도 내가 내 요청에이 이름을 추가해야하는 Nsstring 노래를 X509_NAme로 변환 할 수 있습니까? 사전에
덕분에 나는있는 NSString에 대해 잘 모르지만, 당신은 X509_NAME *에서 이런 식으로 C 스타일 문자열을 얻을 수 있습니다
감사 당신이 코드 스 니펫을 통해 그것을 할 – user564963