如何使用 java 和 bouncy castle 仅解析 ASN.1 数据中的一个标签号

How to parse only one tag number in ASN.1 data with java and bouncy castle

我有这个 ASN.1 结构 ASN.1 editor image 并且想解析标签 12:

Tag: 12 (0x0C) : UTF8String
Offset: 82 (0x52)
Length: 39 (0x27)
Deepness: 7
Path: /0/1/0/0/0/1/0

并在变量中解析 UTF8String

到目前为止,我可以解析整个 ASN.1 结构并将其转储为字符串:

ASN1Sequence responseASN1 = ASN1Sequence.getInstance(streamOut.toByteArray());
System.out.println(ASN1Dump.dumpAsString(responseASN1))

如何只显式解析标记 12 中的 UTF8String


整个结构base64编码:

T2Zmc2V0fExlbmd0aHxMZW5CeXRlfA0KPT09PT09Kz09PT09PSs9PT09PT09Kz09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PQ0KICAgICAwfCAgMTU3NHwgICAgICAzfCAgIFNFUVVFTkNFIDogDQogICAgIDR8ICAxNTcwfCAgICAgIDN8ICAgICAgU0VRVUVOQ0UgOiANCiAgICAgOHwgICAgNTl8ICAgICAgMXwgICAgICAgICBTRVFVRU5DRSA6IA0KICAgIDEwfCAgICAgMXwgICAgICAxfCAgICAgICAgICAgIElOVEVHRVIgOiAnMicNCiAgICAxM3wgICAgMzJ8ICAgICAgMXwgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICg0KSA6IA0KICAgIDE1fCAgICAzMHwgICAgICAxfCAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICAgMTd8ICAgIDI4fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgU0VUIDogDQogICAgMTl8ICAgIDI2fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgICAyMXwgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6ICdDTiAoMi41LjQuMyknDQogICAgMjZ8ICAgIDE5fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgVVRGOFN0cmluZyA6ICdSZWYgU2VydmVyIFNpZ24nDQogICAgNDd8ICAgICAyfCAgICAgIDF8ICAgICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoNCkgOiAnMzAwMCcNCiAgICA1MXwgICAgIDd8ICAgICAgMXwgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICg0KSA6IA0KICAgIDUzfCAgICAgNXwgICAgICAxfCAgICAgICAgICAgICAgIE9DVEVUX1NUUklORyA6ICczMjMzMzQzNTM2Jw0KICAgIDYwfCAgICAgN3wgICAgICAxfCAgICAgICAgICAgIENPTlRFWFQgU1BFQ0lGSUMgKDYpIDogDQogICAgNjJ8ICAgICA1fCAgICAgIDF8ICAgICAgICAgICAgICAgT0NURVRfU1RSSU5HIDogJzMxMzIzMzM0MzUnDQogICAgNjl8ICAgIDY1fCAgICAgIDF8ICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoMTIpIDogDQogICAgNzF8ICAgIDYzfCAgICAgIDF8ICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgICA3M3wgICAgNDh8ICAgICAgMXwgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgIDc1fCAgICA0NnwgICAgICAxfCAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICAgNzd8ICAgICAxfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgSU5URUdFUiA6ICcyJw0KICAgIDgwfCAgICA0MXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICAgODJ8ICAgIDM5fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgVVRGOFN0cmluZyA6IA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICoqKiogU09NRSBURVhUIEhFUkUgKioqKioNCiAgIDEyM3wgICAgMTF8ICAgICAgMXwgICAgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICgwKSA6IA0KICAgMTI1fCAgICAgOXwgICAgICAxfCAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICAxMjd8ICAgICA3fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDEyOXwgICAgIDJ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICg0KSA6ICczMDAwJw0KICAgMTMzfCAgICAgMXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIElOVEVHRVIgOiAnMCcNCiAgIDEzNnwgICAyNjF8ICAgICAgM3wgICAgICAgICBDT05URVhUIFNQRUNJRklDICgwKSA6IA0KICAgMTQwfCAgIDI1N3wgICAgICAzfCAgICAgICAgICAgIEJJVF9TVFJJTkcgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICBVbnVzZWQgYml0czogMCA6IDgwRjAyQjMxQkFBMUM1NkE0OTFERThBMkY2NkIwQjI2QkRBRkJCQTNEMjExQzZENERFRQ0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgIDVFMDhFREE5QzEyNkVGQjExNTVCMkQ2RjMzQUYxRTUxQjU1NjY0NkEyRDgzMzNGRUI0NTgxMkNDNkVBODc5NkJCMDI4DQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgQ0YzRjg0MjY1ODJDMzU5RTNGQzNCRjEzMzVCQUYzMDZGNTQ1OUE4OTY2Q0IyRENDNTkyNjM3OThCNUVFMDA3M0VFRDYNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICA2RkUwQjZCOTdGNjk0MUU0REM4MDZDODFFQzFCQzA1MTAzWFgxODA4MzQ1RTdFRTUyQ0Q1QTAyMzBFMzgwNkUxMTcwNw0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgIDhGNEREQkVFMUUzMUM4RDREQUQyRUY3RjYxMUJCMzE5MjYwMkU5REJDODdGOUNFNTFFM0IzQzg4QjhFRUY5QjBFMzUyDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgRjRGNzZGNDFENkJCMkZERTE5NTk2OTNBRUUyNzZFNUY1QUY1OEI3MEUzNjZCMkYzMDRBMDk3RUEzN0MzNDZGQkI3MUENCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICBEQjM1REM0QTlCMTIxNUMyOEMxNTk3MTY3NUE3RTEzM0Q4MDkzOEU5REU1Q0U0MERFODlEMEFFMUU4NTE0QTU4ODE4Mw0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgIEZCM0QyQTc2MzE4Mjk1RjlFMTdDRTk4NTBDNDgzQjdEMUY1OTJDMzQ5RjI1MDA5REYwMzQ4DQogICA0MDF8ICAxMTczfCAgICAgIDN8ICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoMSkgOiANCiAgIDQwNXwgIDExNjl8ICAgICAgM3wgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgNDA5fCAgMTE2NXwgICAgICAzfCAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA0MTN8ICAgODg1fCAgICAgIDN8ICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDQxN3wgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICgwKSA6IA0KICAgNDE5fCAgICAgMXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIElOVEVHRVIgOiAnMicNCiAgIDQyMnwgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICBJTlRFR0VSIDogJzEwNDEwODQnDQogICA0Mjd8ICAgIDEzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDQyOXwgICAgIDl8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6IA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgIHNoYTI1NlJTQSAoMS4yLjg0MC4xMTM1NDkuMS4xLjExKQ0KICAgNDQwfCAgICAgMHwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIE5VTEwgOiANCiAgIDQ0MnwgICAgODJ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgNDQ0fCAgICAxMXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIFNFVCA6IA0KICAgNDQ2fCAgICAgOXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA0NDh8ICAgICAzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiAnQyAoMi41LjQuNiknDQogICA0NTN8ICAgICAyfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUHJpbnRhYmxlU3RyaW5nIDogJ0RFJw0KICAgNDU3fCAgICAyMXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIFNFVCA6IA0KICAgNDU5fCAgICAxOXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA0NjF8ICAgICAzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiAnTyAoMi41LjQuMTApJw0KICAgNDY2fCAgICAxMnwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFVURjhTdHJpbmcgOiAneHh4IEdtYkgnDQogICA0ODB8ICAgIDQ0fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgU0VUIDogDQogICA0ODJ8ICAgIDQyfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDQ4NHwgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6ICdDTiAoMi41LjQuMyknDQogICA0ODl8ICAgIDM1fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVVRGOFN0cmluZyA6IA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHh4eHggQ0EgMSAyMDEzDQogICA1MjZ8ICAgIDMwfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDUyOHwgICAgMTN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICBVVENUaW1lIDogJzAyLjEwLjIwMTMgMDg6MzUnDQogICA1NDN8ICAgIDEzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgVVRDVGltZSA6ICcwMi4xMC4yMDE2IDA4OjM1Jw0KICAgNTU4fCAgICA4NHwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA1NjB8ICAgIDExfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgU0VUIDogDQogICA1NjJ8ICAgICA5fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDU2NHwgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6ICdDICgyLjUuNC42KScNCiAgIDU2OXwgICAgIDJ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBQcmludGFibGVTdHJpbmcgOiAnREUnDQogICA1NzN8ICAgIDIxfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgU0VUIDogDQogICA1NzV8ICAgIDE5fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDU3N3wgICAgIDN8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6ICdPICgyLjUuNC4xMCknDQogICA1ODJ8ICAgIDEyfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVVRGOFN0cmluZyA6ICd4eHggR21iSCcNCiAgIDU5NnwgICAgMTZ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICBTRVQgOiANCiAgIDU5OHwgICAgMTR8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgNjAwfCAgICAgM3wgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9CSkVDVF9JREVOVElGSUVSIDogJ09VICgyLjUuNC4xMSknDQogICA2MDV8ICAgICA3fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgVVRGOFN0cmluZyA6ICd4eHggUmVmJw0KICAgNjE0fCAgICAyOHwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIFNFVCA6IA0KICAgNjE2fCAgICAyNnwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA2MTh8ICAgICAzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiAnQ04gKDIuNS40LjMpJw0KICAgNjIzfCAgICAxOXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFVURjhTdHJpbmcgOiAneHh4IFJlZiBTZXJ2ZXIgU2lnbicNCiAgIDY0NHwgICAyOTB8ICAgICAgM3wgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgNjQ4fCAgICAxM3wgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA2NTB8ICAgICA5fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiAnUlNBICgxLjIuODQwLjExMzU0OS4xLjEuMSknDQogICA2NjF8ICAgICAwfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgTlVMTCA6IA0KICAgNjYzfCAgIDI3MXwgICAgICAzfCAgICAgICAgICAgICAgICAgICAgICAgIEJJVF9TVFJJTkcgOiANCiAgIDY2OHwgICAyNjZ8ICAgICAgM3wgICAgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgNjcyfCAgIDI1N3wgICAgICAzfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOVEVHRVIgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxOTE1MzA5OTUyMzE0NjQ4NDA1OTI5MjczMjIxNTI5OTU3ODExNzEzNzQ0ODMwMTA3OA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDIyMzIwNzEyODE5NjkzMzAyNjM4NjM5MzUwMDA0NzY0MzMwMTE5NTY3MDIwMTEyMTExDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMzMwMjEzMjA5NDU3Njk2MTMzNDIzNTk0NTk0MzAxNzEzOTI5ODM5NDIyNjU2MDU5MDUNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA2MDgzOTE2NDk5MjE2MDI0MzE4ODY5MDQzMjM2MDY5MzM4ODYwODQ2ODMxNzgzNzIzNA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDkxOTMwMTE3MjYxODEyMzIxMTUxMDA1OTY4ODkyNzgzMTQyNDM5NjA5ODg4MDE2MjMzDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMjI1MDI5MzEyNTc0ODc1MDAwNzM5MzQzMDM2MDg2NDM4NTk1MDI1MTk1NjE0NDc1NzcNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA4OTYxMjE3NTIyMzgyMjk2OTY2MDgwMzg0Nzk0MTk1MzQxMDE5MzM1NTIwNjAxMDA5Mg0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDA3MDYyODIwMTczMjAyNjE2MjIzMjY1MjgxMTA0NzU3MDU5Mjg3NTM0NzA2MzI5NjQ3DQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMzEyMDM1MzI3OTA2ODA1MDgyNTk0NDUzNTEyMDE0OTE1ODA0MTA4NTUxMTY4MDQxMDUNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA4MTM2OTE2MjY0MDg0NjYzMTc3Mzc1NTMzOTc0MDkyOTQ2MDU5Mjc4NTc2ODQ2NTQzNg0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDAyNzAwMzkyMTQ3OTk5MDI3NDc5ODAxOTA0ODU0MDg4MzQwMTY2Mjc0NjA4MDMyODAwDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgNDUwNzE1MDY2ODQ4Nzk3NzU3OTQwMDk5MDQxMzg4MDU1MDQ0Njk3MDMxNjQyOTIyMjINCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAwNjQ2MjIwNTk3ODIyNDM3OQ0KICAgOTMzfCAgICAgM3wgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIElOVEVHRVIgOiAnNjU1MzcnDQogICA5Mzh8ICAgMzYwfCAgICAgIDN8ICAgICAgICAgICAgICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoMykgOiANCiAgIDk0MnwgICAzNTZ8ICAgICAgM3wgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgOTQ2fCAgICAyOXwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA5NDh8ICAgICAzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTY2hsw7xzc2Vsa2VubnVuZyBkZXMgQW50cmFnc3RlbGxlcnMgKDIuNS4yOS4xNCkNCiAgIDk1M3wgICAgMjJ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQ1RFVF9TVFJJTkcgOiANCiAgIDk1NXwgICAgMjB8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQ1RFVF9TVFJJTkcgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBCQjNEQUQ4QTJBMzE4Q0JCNzY1MjlEQTk4NjE4QzdGOTYxRDY1Q0ZEDQogICA5Nzd8ICAgIDU2fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgIDk3OXwgICAgIDh8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6IA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFp1Z3JpZmYgYXVmIFN0ZWxsZW5pbmZvcm1hdGlvbmVuICgxLjMuNi4xLjUuNS43LjEuDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgMSkNCiAgIDk4OXwgICAgNDR8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPQ1RFVF9TVFJJTkcgOiANCiAgIDk5MXwgICAgNDJ8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAgOTkzfCAgICA0MHwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogICA5OTV8ICAgICA4fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBPbmxpbmVzdGF0dXNwcm90b2tvbGwgZGVzIFplcnRpZmlrYXRzICgxLg0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDMuNi4xLjUuNS43LjQ4LjEpDQogIDEwMDV8ICAgIDI4fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoNikgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBodHRwOi8veHh4eC8NCiAgMTAzNXwgICAgMzF8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAxMDM3fCAgICAgM3wgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9CSkVDVF9JREVOVElGSUVSIDogDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU3RlbGxlbnNjaGzDvHNzZWxrZW5udW5nICgyLjUuMjkuMzUpDQogIDEwNDJ8ICAgIDI0fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0NURVRfU1RSSU5HIDogDQogIDEwNDR8ICAgIDIyfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgMTA0NnwgICAgMjB8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICgwKSA6IA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIEJFREFFRDg4RDVDQUMxOTc3QUZFOUJCMUIxNEVFRDcyOTRDQzU1REQNCiAgMTA2OHwgICAgMTR8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICBTRVFVRU5DRSA6IA0KICAxMDcwfCAgICAgM3wgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9CSkVDVF9JREVOVElGSUVSIDogDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU2NobMO8c3NlbHZlcndlbmR1bmcgKDIuNS4yOS4xNSkNCiAgMTA3NXwgICAgIDF8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBCT09MRUFOIDogJ1RydWUnDQogIDEwNzh8ICAgICA0fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0NURVRfU1RSSU5HIDogDQogIDEwODB8ICAgICAyfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQklUX1NUUklORyA6ICdVbnVzZWQgYml0czogNCA6IEIwJw0KICAxMDg0fCAgIDIxNXwgICAgICAyfCAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogIDEwODd8ICAgICAzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgT0JKRUNUX0lERU5USUZJRVIgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBTcGVycmxpc3Rlbi1WZXJ0ZWlsdW5nc3B1bmt0ZSAoMi41LjI5LjMxKQ0KICAxMDkyfCAgIDIwN3wgICAgICAyfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIE9DVEVUX1NUUklORyA6IA0KICAxMDk1fCAgIDIwNHwgICAgICAyfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNFUVVFTkNFIDogDQogIDEwOTh8ICAgMjAxfCAgICAgIDJ8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgMTEwMXwgICAxOTh8ICAgICAgMnwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBDT05URVhUIFNQRUNJRklDICgwKSA6IA0KICAxMTA0fCAgIDE5NXwgICAgICAyfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENPTlRFWFQgU1BFQ0lGSUMgKDApIDogDQogIDExMDd8ICAgMTI1fCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ09OVEVYVCBTUEVDSUZJQyAoNikgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBsZGFwOi8veHh4eEM9REU/Y2VydGkNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWNhdGVyZXZvY2F0aW9ubGlzdA0KICAxMjM0fCAgICA2NnwgICAgICAxfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIENPTlRFWFQgU1BFQ0lGSUMgKDYpIDogDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaHR0cDovL3h4eHhjYV8xXzIwMTMuY3JsDQogIDEzMDJ8ICAgIDEzfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgU0VRVUVOQ0UgOiANCiAgMTMwNHwgICAgIDl8ICAgICAgMXwgICAgICAgICAgICAgICAgICAgICBPQkpFQ1RfSURFTlRJRklFUiA6ICdzaGEyNTZSU0EgKDEuMi44NDAuMTEzNTQ5LjEuMS4xMSknDQogIDEzMTV8ICAgICAwfCAgICAgIDF8ICAgICAgICAgICAgICAgICAgICAgTlVMTCA6IA0KICAxMzE3fCAgIDI1N3wgICAgICAzfCAgICAgICAgICAgICAgICAgIEJJVF9TVFJJTkcgOiANCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICBVbnVzZWQgYml0czogMCA6IDgwNTRENkRDRDlEQjdFMTRFMzVERjE2OUZCNkZCMDZFREQ3RTZBREU1NDJDMA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgIDQzRjk1QzQ1OTc4NEJCQjMyNUVFQjU5Q0E5MTFGRTdGOTJCNzY5NUNBMjZGREVBODY3OUM2NkYwNUQ2NzFGDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgOUYzNEZDOUQ0RTc3OTJBODFBMDFGNEMxRUFGOUNFRjUzODc3MDhFNzRCREE0OEJBNTdENjRGM0NFMzMyRTYNCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICAzNjA2MjkwODUyRDNDRjBCRjkyMzhGNEFFMTcyRTMwQjJGNEQ2Mjk3RDMwNzE1OTVGNDE5ODlERjk3MDk4Rg0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgIDQ0M0FENDExNTU3NkU0M0FDNEE2NUUxRUQzODc0MTkzNzA5QTREODE3QjI0MUIwRTk0NzM4OTRFMzU5MUZEDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgNTI1QzE1MjFFRDZCQUNCQjQ2ODJGN0NEMDM1NjM2OURCMTU0NjM1RUI5ODE3RkFGNzNEQURFMDE5OTlGQUENCiAgICAgIHwgICAgICB8ICAgICAgIHwgICAgICAgICAgICAgICAgICAgICA3RTA4QTY2QUI1Njk3OUQ5MTFGREMxNjA1NjE2QjhDQ0JBREY2OTg5MTdDQTczMjFBNDVCOUMxOTQ4MTg5RA0KICAgICAgfCAgICAgIHwgICAgICAgfCAgICAgICAgICAgICAgICAgICAgIDFGMDFDRjlDNkYxOUMyOTI5RTU1RjgwNzk3MjVCMTA2RjU0MDExRjYzMzU3RDI1RjdFMjVBMTEzRDAwNTAxDQogICAgICB8ICAgICAgfCAgICAgICB8ICAgICAgICAgICAgICAgICAgICAgQ0M4Qjk5MEExMkQ3RUQ1QTBFQ0Q5QzYzM0NGNzFDQzA0DQo=

我无法重新创建整个结构,但我已经根据您提供的图像编写了一些代码。我正在使用 BouncyCastle 1.56

查看ASN.1结构,基本上是(省略一些数据以使其更简单):

SEQUENCE : // 1 (I'm assuming this is responseASN1)
    SEQUENCE : // 2 (first element of sequence 1)
        SEQUENCE : // 3 (first element of sequence 2)
            ... tag 12 is not here
        CONTEXT SPECIFIC (12) : // 4 (second element of sequence 2)
            SEQUENCE : // 5 (tag 12 value)
                SEQUENCE : // 6 (first element of sequence 5)
                    SEQUENCE : // 7 (first element of sequence 6)
                        INTEGER: // (first element of sequence 7)
                        SEQUENCE: // 8 (second element of sequence 7)
                            UTF8String: // 9 (first element of sequence 8)
                                ******* SOME TEXT HERE ****

请注意,我添加了一些数字以使我的答案更加清晰。

所以,要得到UTF8String,你必须经过这个结构。考虑到responseASN1是序列1,可以做如下操作:

ASN1Sequence seq2 = (ASN1Sequence) responseASN1.getObjectAt(0); // get sequence 2
// ignore sequence 3, because tag 12 is in CONTEXT SPECIFIC 
DERTaggedObject contextSpecific = (DERTaggedObject) seq2.getObjectAt(1); // the second element of sequence 2
ASN1Sequence seq5 = (ASN1Sequence) contextSpecific.getObject(); // get sequence 5
ASN1Sequence seq6 = (ASN1Sequence) seq5.getObjectAt(0); // get sequence 6
ASN1Sequence seq7 = (ASN1Sequence) seq6.getObjectAt(0); // get sequence 7
ASN1Sequence seq8 = (ASN1Sequence) seq7.getObjectAt(1); // get sequence 8 (second element of sequence 7)
DERUTF8String utf8String = (DERUTF8String) seq8.getObjectAt(0); // finally get the UTF8String
System.out.println(utf8String.getString()); // the string you want